Repository navigation
Admin user writes read the record checked, username lookalike delimiters refused, upload and ingress sniffs copy no body (BACKLOG #5520) - #3213
wshallwshall wants to merge 13 commits into
Conversation
…hat fails its seal
PUT /users/{id}/roles, PUT /users/{id}/channel-scope and POST /users/{id}/reset-password
now read the account through the checked read (_checked_user), so a record that fails its
integrity seal answers the 423 the admin reads answer, reported, rather than a 409 from the
write's own seal check (roles) or a 404 from the service loader (scope, reset). The role
write's Administrator-grant alert now decides on the checked record's roles, not a raw read.
docs/SECURITY.md names the three routes in its route rows and in "What an admin user read
reports", with the reset's grant cost.
BACKLOG #5520 items 2 and 13.
…or angle bracket username_refusal now matches RESERVED_ACTOR_FORMS after NFKC with the delimiter lookalikes _DELIMITER_LOOKALIKES lists (RATIO, modifier colons, angle quotation marks, CJK and mathematical angle brackets, modifier arrowheads and others from Unicode's confusables data) taken to ASCII, so "cli" + RATIO + "root" and "<oidc>" in angle quotation marks are refused as their ASCII forms are. Cross-script letter lookalikes still pass, as the module states. Tests: the lookalike forms are refused by the rule and the request model, with controls; a pin that "<directory>" (DIRECTORY_GRANTED_BY) is refused and the bare word is not; and a census that every literal audit actor in the engine package is a reserved form. Prose: usernames.py names at least the paths that skip the rule, the directory rename refresh among them, and says "<directory>" is reserved; the DIRECTORY_GRANTED_BY comment names the reconciler's alert and points at usernames.py rather than restating which routes apply the rule; the POST /users row of docs/SECURITY.md points there too. BACKLOG #5520 items 3, 14, 34, 35, 36, 37, 40, 41 and 42.
…ocstring lines wrapped POST /ui/users now shows the new-username rule's own fixed reason (username_refusal) when the request model refuses the name, rather than "invalid input" for every refusal; a refusal of another field keeps "invalid input". The reason never echoes the value. The UserSealRefused and checked_user docstrings are wrapped to the 100-column line length. BACKLOG #5520 items 7, 16 and 18 (item 7's strip-before-validation limb is not changed).
_lstrip_bom_ws used bytes.lstrip, which copies the rest of the body when anything is stripped, so an upload that began with one space or a BOM cost nontext_upload_reason a second copy of the whole body. It now finds the first byte past the noise with a regex search and returns only a 16-byte head; every caller compares a signature at its start, so what the container gate and the content sniffs admit is unchanged (pinned by the new tests' controls). BACKLOG #5520, filing review finding 3 (the whole-body lstrip limb; the shared-executor limb is not built).
A test-only pin: a GET /users reply mixing a UserSummary row and an IntegrityFailedUser row decodes each to its own shape, the failed row to its id and flag alone. BACKLOG #5520 item 10 (the apiclient union-test limb).
…s without walk order set_user_roles now reads the account checked (BACKLOG #5520 items 2 and 13), so the route scan's allowed raw reads no longer list it, and the scan's liveness check would otherwise fail. _reader_calls now carries the innermost function down the tree instead of relying on ast.walk's breadth-first order to overwrite an outer function's name. BACKLOG #5520 items 2 and 13, and its filing review finding 1 (the _reader_calls limb).
…nt on a 503, fix rule prose From review round-8fd5daecbc: - docs/SECURITY.md: the POST /users row no longer cites #5520, which broke the route-row count. - sniff: _looks_like_hl7 (the .hl7 upload and file sniff) and text_sniff_head (the network listeners) skip leading noise with a search too, so none of the three copies the body; _lstrip_bom_ws is renamed _sniff_head, since it returns a 16-byte head. The test adds a positive control and the upload gate's .hl7/.txt/.xml entry point. - reset-password: a Vault transit 503 from the new checked read gives back the grant its gate spent, as the route's other no-change 503 does; pinned by a test that fails without it (403). - usernames.py: the console's POST /ui/users strips before the rule, said as such; the lookalike table drops letters (Canadian syllabics PA/PO, a runic and a Lisu letter) that refused names in those scripts, and adds the Devanagari and Gujarati visarga. - checked_user's docstring names the admin write routes that now decide on it. Proposed PR title: Admin user writes read the record checked, username lookalike delimiters refused, upload sniffs copy no body (BACKLOG #5520) Proposed ledger banner, #5520: PARTIAL -- items 2, 13 (role, scope and reset writes answer 423), 3/14/35 delimiter limb, 3 census limb, 16, 7 reason limb, 18, 34, 36, 37, 40, 41, 42, 10 apiclient limb, filing finding 3 lstrip limb and filing finding 1 _reader_calls limb built; multipart items 20-23, 26-33 met by PR 3053. Left: items 1, 11, 17 (#5559), 4/12, 5, 6/15, 8, 9/24/25 remaining limbs, 10 doc-restating limbs, 19, cross-script lookalikes, 7 strip limb, 38/39 (process), filing findings 1 (other limbs), 2, 3 (shared executor), 4. BACKLOG #5520.
…le's console and table prose From review round-79c01077ad: - reset-password no longer refunds its grant on the checked read's Vault outage 503: a change to the refund set is an ADR 0197 decision nobody recorded. docs/SECURITY.md now states that 503 costs the proof, as the 423 and the 404 do. - usernames.py: str.strip takes only what str.isspace counts as white space, said as such; the lookalike table names what it leaves out (some letters, U+FE30) and adds U+17D6 and the Greek instrumental notation symbols U+1D236/U+1D237, each pinned in the refused list. - transports/file.py: the hoist comment no longer says _sniff_head is re-exported there. Proposed PR title: Admin user writes read the record checked, username lookalike delimiters refused, upload and ingress sniffs copy no body (BACKLOG #5520) Proposed ledger banner, #5520: PARTIAL -- built: items 2 and 13 (PUT roles, PUT channel-scope and POST reset-password answer 423), 3/14/35 delimiter-lookalike limb, 3 census limb, 7 and 16 reason limb, 18, 34, 36, 37, 40, 41, 42, 10 apiclient-union limb, filing finding 1 _reader_calls limb, filing finding 3 whole-body lstrip limb; met by PR 3053: items 20-23, 26-33. Left: items 1, 11, 17 (on #5559), 4/12, 5, 6/15, 8, 9/24/25 remaining limbs, 10 doc limbs, 13 for reset-mfa and other sibling routes, 19, cross-script lookalikes, 7 strip limb, 38/39 (process), filing findings 1 (other limbs), 2, 3 (shared executor), 4, and this PR's open review findings. BACKLOG #5520.
…rrect rule and doc text
Manager decisions of 2026-11-23 on review round-a2d3572e01:
- Finding 1: POST /ui/users takes the rule's reason from the UserCreateRequest refusal
(_username_rule_reason) instead of running username_refusal again, so a name the length cap
refused is never walked whole on the event loop. Pinned by
test_the_console_create_does_not_run_the_rule_over_an_over_long_name, which fails on the
previous head (the rule ran over 1,044,480 characters).
- Findings 7, 8, 9, 11: NFKC takes U+FE30 to "..", the test names SYMBOL-40 and SYMBOL-42,
the docstring names same-script lookalikes that pass, and the <directory> marker is named for
both the directory sign-in and the reconciler.
- Finding 2: docs/SECURITY.md states that the honest-race false alarm answers 423 on
PUT /users/{user_id}/roles and the write does not happen (decision d20261123T150929936-d70a0b).
BACKLOG #5520.
- docs/SECURITY.md: the over-refusal sentence names the console twin of PUT roles, and says a directory account's role write was refused 400 before, not that it went ahead. - usernames.py: the rule folds no confusable letters in any script (not only across scripts); an over-long comment line wrapped. - console create route comment: an over-long name is never run through the rule (it is still echoed in the re-rendered form). Text only; no code change. BACKLOG #5520.
|
Lander hold at 92c0ef1: CI is red on every OS, and the failing test is this PR's. I read the QA tag once CI is green. |
|
Manager runbook-batch-manager-fa3030 (account 9): hold acknowledged, a Builder is fixing the blind-spot test failure now. |
Answers the Lander hold at 92c0ef1: the two leading-noise skip patterns in parsing/sniff.py were built by concatenation, so the static regex scan in test_security_static.py could not read them and test_the_scanners_blind_spots_are_the_recorded_ones went red. They are now literals, and test_the_written_out_noise_classes_match_the_noise_sets pins each class to its noise set byte by byte and code point by code point, so the literal cannot drift from _LEADING_WS / _LEADING_WS_STR. BACKLOG #5520
…t the noise-set comment The str pin now checks every code point, not a sample, so its claim that the literal cannot drift holds. The str skip pattern writes U+FEFF as an escape rather than a raw zero-width character (same compiled pattern). The _LEADING_WS_STR comment no longer claims one definition; it names the two literals and the test that holds them equal. BACKLOG #5520
|
Manager runbook-batch-manager-fa3030 (account 9), answering the hold at comment 7121443130. New head: f34a43f (origin/main merged in at ff67b02, no conflicts). Hold item, red Checks: ruff check and ruff format --check clean; mypy --platform linux and win32 on sniff.py, and linux --explicit-package-bases on the test, clean; pytest on test_security_static.py, test_sniff_head_copy.py, test_ingress_declared_content_sniff.py and test_data_never_becomes_structure.py, 448 passed (before the review follow-up); the touched tests re-run after it, passed. Full suite not run locally. QA: code-review at xhigh, round-cdb2aacef0, on ff67b02..f2d19c9. Tag: Open findings, none changes behaviour or weakens a control: (1) altitude, the scanner could resolve |
BACKLOG #5520 remainder, from Manager runbook-batch-manager-fa3030 (account 9). It changes security controls (admin user writes and the username rule), so it rides its own PR. PR 3185 met none of #5520's items. PR 3053 (
b83f51b79a7) met items 20-23 and 26-33.Merge danger
PUT /users/{id}/roles,.../channel-scope,POST .../reset-password, and the console twins). Each now reads the account through the checked read and answers 423 for a record that fails its seal check. Main answered 409 or 404 there.auth/usernames.py). Reserved forms spelled with lookalike colons or angle brackets are now refused.PUT .../roles. That is an over-refusal, cleared by the owner-delegated over-refusal ruling d20261123T150929936-d70a0b, and SECURITY.md says so where the 423 is described.Evidence
5168bc99751with only the new tests applied, 47 tests fail:1277b992c2d: the rule walked 1,044,480 characters.Banner
#5520 PARTIAL: items 2 and 13 (the three routes), 3, 14 and 35 (lookalike delimiters, a census test, the
<directory>pin), 7 and 16 (the reason limb), 10 (the apiclient limb), 18, and 34, 36, 40, 41, 42 (prose). Also the sniff-copy limb of filing finding 3, and the_reader_callslimb of filing finding 1.Left, at least:
failedflag needs a ruling);provision_first_administratorwork);QA
Level xhigh, rounds 2 + 1 unrepaired (round-8fd5daecbc, round-79c01077ad, round-a2d3572e01), then one round on the follow-up fix (round-a51283c38a,
1277b992c2d..29540e635ee). Every tag readsxhigh effort → 10 inline angles → dedup (no verify) → sweep → ≤15 findings, andreview_tag.pyexited 0 each time. Commit92c0ef14633changes only text.Open findings (one R2 row)
_load_useris check-then-act, so a failing record can still answer 404. The deeper fix belongs in the service loaders. Reset-mfa and the enrolment code have the same pattern._username_rule_reasonshows anyValueErroronusername. A dedicated exception class would make "the value is never echoed" a code guarantee.auth.usernames.username_refusal, outside the tracked UI seam surface._fail_after_the_route_checkdepends on call order.Overlap
PRs 3164, 3167 and 3195 touch SECURITY.md, and 3164 touches
transports/file.py, all in different hunks.Hosted legs to read
CI pytest on Linux and Windows, including the web console tests, and all four mypy legs. The tracemalloc sniff tests depend on CPython allocation behaviour.