Skip to content

[WRONG BRANCH] fix(lab): reject POSIX file URIs - #243

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-file-/-posix-path-bypass
Draft

[WRONG BRANCH] fix(lab): reject POSIX file URIs#243
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-file-/-posix-path-bypass

Conversation

@luvs01

@luvs01 luvs01 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A recent tightening of the raw POSIX path detector regressed detection for file:/// absolute POSIX URIs, allowing sensitive local paths such as file:///etc/passwd to pass the lab event privacy admission checks.

Description

  • Add a case-insensitive FILE_POSIX_URI_RE regex and include it in the string admission checks inside enforceEventStructureLimits so file:///… forms are rejected as raw_path alongside other raw path forms. 【F:src/lab/events/limits.ts†L34-L36】【F:src/lab/events/limits.ts†L82-L89】
  • Add regression coverage to tests/lab-post-merge-hardening.test.ts to assert that file:///etc/passwd and file:///home/alice/secret.txt are rejected by the admission checks. 【F:tests/lab-post-merge-hardening.test.ts†L182-L203】

Testing

  • ./node_modules/.bin/bun scripts/test.ts tests/lab-post-merge-hardening.test.ts — the focused test file passed.
  • bun run typecheck — TypeScript typecheck passed.
  • bun run privacy:scan — privacy scan passed.
  • Attempted bun run test (full suite) surfaced an unrelated environment timeout in a long-running key-login test during one run; focused tests, typecheck, and privacy:scan were green and the targeted regression is covered by the focused test.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Improved privacy validation by rejecting POSIX file:/// URIs that reference system or home-directory paths.
    • These values now produce a clear raw_path validation error.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot changed the title fix(lab): reject POSIX file URIs [WRONG BRANCH] fix(lab): reject POSIX file URIs Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Raw path validation now rejects case-insensitive file:/// POSIX URIs. Privacy tests cover system and home-directory file URI targets.

Changes

Raw path privacy validation

Layer / File(s) Summary
Reject POSIX file URIs
src/lab/events/limits.ts, tests/lab-post-merge-hardening.test.ts
The validator detects case-insensitive file:/// URIs and rejects them with raw_path. Tests cover /etc/passwd and a home-directory secret file.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: rejecting POSIX file URIs in lab privacy checks.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/propose-fix-for-file-/-posix-path-bypass

Comment @coderabbitai help to get the list of available commands.

@github-actions
github-actions Bot marked this pull request as draft August 11, 2026 00:29
@github-actions github-actions Bot added the bug Something isn't working label Aug 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/lab-post-merge-hardening.test.ts`:
- Around line 194-195: Update the file-URI test cases in the focused regression
test to include a mixed-case `file:///` detail value, while retaining the
existing `raw_path` assertion and lowercase cases. Ensure the test exercises the
case-insensitive matching behavior implemented by `FILE_POSIX_URI_RE` in the
limits logic.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3183a92d-f17c-4332-a173-3cc6051e173c

📥 Commits

Reviewing files that changed from the base of the PR and between 6d881db and 07f53ad.

📒 Files selected for processing (2)
  • src/lab/events/limits.ts
  • tests/lab-post-merge-hardening.test.ts

Comment on lines +194 to +195
"detail=file:///etc/passwd",
"detail=file:///home/alice/secret.txt",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add a mixed-case file:/// regression case.

The current values are lowercase, so they verify rejection but not case-insensitive matching. If the i flag is removed from FILE_POSIX_URI_RE, these tests still pass. Add a mixed-case value and retain the existing raw_path assertion.

As per path instructions, the focused regression test should cover the behavior changed in src/lab/events/limits.ts.

Proposed test addition
     "detail=file:///etc/passwd",
     "detail=file:///home/alice/secret.txt",
+    "detail=FiLe:///etc/passwd",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"detail=file:///etc/passwd",
"detail=file:///home/alice/secret.txt",
"detail=file:///etc/passwd",
"detail=file:///home/alice/secret.txt",
"detail=FiLe:///etc/passwd",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/lab-post-merge-hardening.test.ts` around lines 194 - 195, Update the
file-URI test cases in the focused regression test to include a mixed-case
`file:///` detail value, while retaining the existing `raw_path` assertion and
lowercase cases. Ensure the test exercises the case-insensitive matching
behavior implemented by `FILE_POSIX_URI_RE` in the limits logic.

Source: Path instructions

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07f53ada90

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lab/events/limits.ts

const RAW_POSIX_PATH_RE =
/(?:^|[^A-Za-z0-9._~/])\/(?:(?=$|[^A-Za-z0-9._~/])|(?!\/)(?![ \t\r\n])(?:\/|[^/\0\r\n]+)+\/?(?=$|[^A-Za-z0-9._~/]))/u;
const FILE_POSIX_URI_RE = /\bfile:\/\/\//i;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize localhost authorities in file URIs

When an event contains a URI such as file://localhost/home/alice/secret.txt, this expression does not match because it requires the path's third slash immediately after file://, while RAW_POSIX_PATH_RE also skips the slashes following an authority. The URL API normalizes this standard local-file form to file:///home/alice/secret.txt, but enforceEventStructureLimits accepts it, so an unsanitized event can still persist the same sensitive local path through the ledger backstop. Match local file URIs with either an empty or localhost authority and add the authority form to the focused regression cases.

Useful? React with 👍 / 👎.

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

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant