fix(pixel-settings): convert decode and protocol failures to unsafe-settings-source - #5697
Open
vaibhavsrv wants to merge 1 commit into
Open
vaibhavsrv wants to merge 1 commit into
vaibhavsrv wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
In
ods/bin/pixel_settings/coordinator.py,_read(path, uid, maximum)safely reads settings documents, root recovery journals, and provider configurations while verifying file descriptor metadata and permissions against the host owner UID. If file attributes change or file size limits are exceeded,_readraisesAccessError("unsafe-settings-source")orAccessError("settings-source-changed").However,
_readdirectly performedraw.decode("utf-8")anddecode_frame(...)without exception handling. When encountering non-UTF-8 bytes or malformed framing (such as unexpected EOF, syntax errors, or duplicate JSON keys),raw.decode("utf-8")raised unhandledUnicodeDecodeErroranddecode_frameraisedProtocolError("owner-protocol-failed"). These unhandled exceptions escaped the privileged access coordinator instead of being converted intoAccessError("unsafe-settings-source"), failing the coordinator's security guarantee that corrupted or unparseable source files are classified as unsafe sources.This surgical fix wraps
raw.decode("utf-8")anddecode_framein atry...except (UnicodeDecodeError, ProtocolError)block that raisesAccessError("unsafe-settings-source") from None.Validation
c._readon a file containing non-UTF-8 bytes (b"\xff\xfe\x00\x00") and unformatted JSON text on unpatchedcoordinator.py. Baseline failed by leaking unhandledUnicodeDecodeErrorandProtocolError.AccessError("unsafe-settings-source").pixel-settings coordinator suites: regression tests passed. New-test syntax and diff checks pass; new regressions wired into test suite.Overlap check
fix(pixel-settings): reject active token limits exceeding provider capacity): Bounds runtime capability values incontract.py; zero overlap with coordinator file I/O incoordinator.py.fix(dashboard-api): tolerate evicted or missing attempts during pixel chat cancel): Touches dashboard API chat result store lifecycle; zero overlap with settings coordinator.fix(pixel-gateway): answer 401 for non-ASCII Authorization headers): Restricts header bytes validation in provider gateway; zero overlap with settings coordinator error handling.fix(pixel-settings): validate runtime capability bounds): Touched capability schema; no overlap with low-level coordinator deserialization.Risk / AI disclosure
AI-assisted investigation, implementation and CLI regressions. This converts raw decoding and protocol exceptions into the coordinator's standard AccessError hierarchy. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.
Follow-up integration evidence
Composed with #5696 at
132e51511without conflicts. Production and test diffs passed together; coordinator and contract checks remain intact.Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.