Skip to content

fix: prevent leaf symlink races in Markdown fixture reads - #76956

Merged
pelikhan merged 1 commit into
mainfrom
pelikhan/codeql-filesystem-race
Nov 11, 2026
Merged

pelikhan merged 1 commit into
mainfrom
pelikhan/codeql-filesystem-race

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

Summary

Addresses CodeQL alert 1102: developer fixture collection checked a path with lstatSync and then read it by pathname, allowing a concurrent leaf symlink replacement to bypass the check.

Open Markdown files with O_RDONLY | O_NOFOLLOW | O_NONBLOCK, require a regular file using fstatSync, read through the opened descriptor, and close it in finally. Existing symlinks remain skipped, directory recursion and embedded Markdown inputs are preserved, and errors propagate normally.

Parent directories must remain trusted; this does not protect against parent-directory replacement. Platforms lacking the required flags fail explicitly instead of using an unsafe fallback. Remote alert closure requires a subsequent CodeQL scan.

Validation

  • Six deterministic regression tests cover fixture collection, existing symlinks, replacement before and after open, non-regular files, and descriptor cleanup on read failure.
  • 388 existing adapter-consumer tests pass.
  • make fmt, make agent-report-progress, and JavaScript syntax checks pass.

Prevent leaf symlink replacement between inspection and read, validate regular files through fstat, and close descriptors on success and failure. Add deterministic fixture collection regression tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review November 11, 2026 20:24
Copilot AI adaptive review requested due to automatic review settings November 11, 2026 20:24
@pelikhan
pelikhan merged commit f301a0c into main Nov 11, 2026
1 check passed
@pelikhan
pelikhan deleted the pelikhan/codeql-filesystem-race branch November 11, 2026 20:24
Copilot stopped reviewing on behalf of pelikhan due to an error November 11, 2026 20:24
@pelikhan
pelikhan removed the request for review from Copilot November 11, 2026 21:43
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

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