Commit graph

5 commits

Author SHA1 Message Date
fusion44
97cbd4cb55
fix(setup): make input validation effective and tighten setup endpoints
password_valid()/name_valid() ended in `return re.match(...)`, which yields a
Match object or None. The setup router tests them with `is False`, and
`None is False` is False, so the charset check never rejected anything --
only the length and space rules were doing any work. The validators now return
real booleans, and use fullmatch: with re.match the trailing `$` also matches
just before a final newline.

Impact is bounded, and this is a correctness bug rather than a vulnerability.
These call sites are reachable only while the node is in `state=waitsetup`,
and that same endpoint hands the caller a signed admin JWT by design, on a
device where blitzapi has passwordless sudo. A malformed hostname reaching the
setup file -- which provisioning sources as bash -- therefore grants nothing
the caller does not already have, and in practice the value comes from the
operator's own setup form. What it does cost: a hostname containing a quote or
`$` corrupts the setup file and breaks provisioning, and the charset gate
would not hold as a defence if the setup flow ever gains operator binding.

Also in this change:

- Gate /setup-start-done and /setup-start-info on setupPhase != "done", as
  /setup/shutdown already does. `state` lives in the unauthenticated key-value
  store, so a local process could flip it back to "waitsetup" on a fully
  provisioned node and be handed an admin JWT. Unlike the above, that is a
  real escalation, because setup is supposed to be closed at that point.
- raise HTTPException instead of returning it (18 sites). FastAPI serialised
  the returned object as a 200 body, so rejections looked like successes; the
  WebUI stored that body as its access token.
- Fix the status.status.HTTP_405_METHOD_NOT_ALLOWED typo (3 sites) that raised
  AttributeError and surfaced as an unhandled 500.
- Create the setup file 0600. It holds passwords A/B/C in cleartext and
  provisioning appends the wallet seed words, on a tmpfs mounted mode=0777.

Regression tests in tests/test_setup_input_validation.py; all nine fail before
this change and pass after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-16 10:51:07 +02:00
fusion44
2b98912796 feat: replace call_script func with better func
use exec_bash_command instead

refs #123
2025-05-06 09:16:46 +02:00
fusion44
adf472ac8b feat: implement Ruff as a linter; fix given errors 2023-06-25 07:17:00 +02:00
pre-commit-ci[bot]
3d1dfd919c
[pre-commit.ci] pre-commit autoupdate (#187)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-02-11 13:47:34 +01:00
fusion44
ba453e7bdb
refactor: switch to domain driven directory layout 2022-10-03 20:22:00 +02:00
Renamed from app/repositories/setup_impl/raspiblitz/router.py (Browse further)