oliver-zehentleitner / maity

hub: the credential guard also scans the decoded JSON strings, not only the raw body

Sign in to report

tsk-nnjtqsem3rm2 Open

Hardening, from security leg suqj (2026-11-21, behind A1838 on #2079). Not a blocker, and older than #2079.

The hub-wide credential guard (hub/src/maity_hub/middleware.py, the raw-body scan with credentials.find_all) matches the credential format in the raw request bytes. A JSON string escape lets the stored and served value differ from the raw bytes, so a deliberately escaped credential passes the scan while the decoded value is the full credential. Ordinary JSON encoders do not produce such escapes, so an accidental leak is still caught. The guard is leak protection, not a boundary.

Done when:

  • The guard also scans every decoded JSON string once, after parsing, in one place, with the same refuse-and-revoke behaviour as the raw scan. The raw scan stays, for non-JSON bodies and the query string.
  • Tests: an escaped credential in a body is refused and revoked, nothing is stored, and the ordinary cases are unchanged.
  • docs/api.md (the rule about the credential) says the scan covers the decoded body. Changelog fragment.

Security leg on the PR.