pihole: app_pwhash is rendered as a hash of the empty string when no app password is set #383

Open
opened 2026-11-25 21:46:58 +00:00 by Claude · 0 comments
Owner

Problem

roles/pihole/templates/pihole.toml.j2:843 always renders:

app_pwhash = "{{ __pihole_effective.config.webserver.api.app_password | hash('sha256') | hash('sha256') }}"

config.webserver.api.app_password defaults to "" (roles/pihole/defaults/main.yml:312). So with no application password, app_pwhash is not empty: it is the double SHA-256 of the empty string.

The comment above that line (841-842) also says the double-hash format "has not been tested". This behaviour comes from the upstream role the template derives from; #372 carried it over unchanged.

Possible impact (not verified)

  • If pihole-FTL treats any non-empty app_pwhash as "an application password is set", then a host that sets no app password may still have one, whose plaintext is the empty string. That would allow an app-password API session past 2FA.
  • If FTL expects another hash format for app_pwhash, the value is ignored or rejected, and a configured app password does not work.

Neither has been checked against pihole-FTL itself. The molecule scenario stubs the installer and runs no FTL.

Proposed work

  • Check in the pihole-FTL source or docs how webserver.api.app_pwhash is read: what an empty value means, and which hash formats are accepted.
  • Render app_pwhash = "" when app_password is empty.
  • Render a non-empty password in the format FTL expects, and drop the "untested" comment.
  • Assert both cases in the scenario's verify.yml: empty password gives an empty app_pwhash; a set password gives the expected hash.
  • Changelog fragment: bugfixes if FTL accepted the empty-string hash as a password, minor_changes otherwise.

Acceptance criteria

  • With the default app_password: "", the rendered pihole.toml has app_pwhash = "".
  • A non-empty app_password renders in the format pihole-FTL accepts, with the source of that format cited in the PR.

Assisted-by: Claude Code:claude-opus-5-5

## Problem `roles/pihole/templates/pihole.toml.j2:843` always renders: ```jinja app_pwhash = "{{ __pihole_effective.config.webserver.api.app_password | hash('sha256') | hash('sha256') }}" ``` `config.webserver.api.app_password` defaults to `""` (`roles/pihole/defaults/main.yml:312`). So with no application password, `app_pwhash` is not empty: it is the double SHA-256 of the empty string. The comment above that line (841-842) also says the double-hash format "has not been tested". This behaviour comes from the upstream role the template derives from; #372 carried it over unchanged. ## Possible impact (not verified) - If pihole-FTL treats any non-empty `app_pwhash` as "an application password is set", then a host that sets no app password may still have one, whose plaintext is the empty string. That would allow an app-password API session past 2FA. - If FTL expects another hash format for `app_pwhash`, the value is ignored or rejected, and a configured app password does not work. Neither has been checked against pihole-FTL itself. The molecule scenario stubs the installer and runs no FTL. ## Proposed work - [ ] Check in the pihole-FTL source or docs how `webserver.api.app_pwhash` is read: what an empty value means, and which hash formats are accepted. - [ ] Render `app_pwhash = ""` when `app_password` is empty. - [ ] Render a non-empty password in the format FTL expects, and drop the "untested" comment. - [ ] Assert both cases in the scenario's `verify.yml`: empty password gives an empty `app_pwhash`; a set password gives the expected hash. - [ ] Changelog fragment: `bugfixes` if FTL accepted the empty-string hash as a password, `minor_changes` otherwise. ## Acceptance criteria - With the default `app_password: ""`, the rendered `pihole.toml` has `app_pwhash = ""`. - A non-empty `app_password` renders in the format pihole-FTL accepts, with the source of that format cited in the PR. Assisted-by: Claude Code:claude-opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#383