Skip to content

fix(security) : Fix race condition in file write operations (Symlink TOCTOU)#1146

Merged
sqrrrl merged 3 commits into
google:masterfrom
l3tchupkt:fix/symlink-toctou-writefiles
Apr 14, 2026
Merged

fix(security) : Fix race condition in file write operations (Symlink TOCTOU)#1146
sqrrrl merged 3 commits into
google:masterfrom
l3tchupkt:fix/symlink-toctou-writefiles

Conversation

@l3tchupkt
Copy link
Copy Markdown
Contributor

@l3tchupkt l3tchupkt commented Apr 9, 2026

fixes(#1148)
Prevent symlink race condition attacks in WriteFiles() that could allow
arbitrary file writes outside the project directory.

Changes:

  • Validate contentDir hasn't been swapped with symlink
  • Check parent directory chain for symlink attacks
  • Use O_NOFOLLOW | O_EXCL flags for atomic file writes
  • Detect and block race conditions during file creation

Fixes: TOCTOU vulnerability in pull/clone operations

  • [x ] npm run test succeeds.
  • [ x] npm run lint succeeds.
  • Appropriate changes to README are included in PR.

@l3tchupkt l3tchupkt changed the title Fix race condition in file write operations (Symlink TOCTOU) fix(security) : Fix race condition in file write operations (Symlink TOCTOU) Apr 10, 2026
@l3tchupkt
Copy link
Copy Markdown
Contributor Author

@sqrrrl please review!!

@sqrrrl sqrrrl merged commit 08e51a3 into google:master Apr 14, 2026
1 check passed
@l3tchupkt
Copy link
Copy Markdown
Contributor Author

Hey @sqrrrl , since this fix addresses a TOCTOU vulnerability that could lead to arbitrary file writes, do you think it makes sense to track it as a security advisory or CVE?

Happy to help with details or writeup if needed.

@l3tchupkt
Copy link
Copy Markdown
Contributor Author

also can you check #1145? I fixed the conflicts there.

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.

2 participants