Skip to content

fix(pixel-settings): convert decode and protocol failures to unsafe-settings-source - #5697

Open
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-settings-read-unsafe-source
Open

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-settings-read-unsafe-source

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

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, _read raises AccessError("unsafe-settings-source") or AccessError("settings-source-changed").

However, _read directly performed raw.decode("utf-8") and decode_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 unhandled UnicodeDecodeError and decode_frame raised ProtocolError ("owner-protocol-failed"). These unhandled exceptions escaped the privileged access coordinator instead of being converted into AccessError("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") and decode_frame in a try...except (UnicodeDecodeError, ProtocolError) block that raises AccessError("unsafe-settings-source") from None.

Validation

  • Baseline reproduction: Executed c._read on a file containing non-UTF-8 bytes (b"\xff\xfe\x00\x00") and unformatted JSON text on unpatched coordinator.py. Baseline failed by leaking unhandled UnicodeDecodeError and ProtocolError.
  • Post-fix behavior: Both invalid UTF-8 and malformed frames raise AccessError("unsafe-settings-source").
  • Telemetry: pixel-settings coordinator suites: regression tests passed. New-test syntax and diff checks pass; new regressions wired into test suite.

Overlap check

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 132e51511 without 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant