Skip to content

Refuse directory-symlink loops to prevent unbounded recursion in addF… - #105

Merged
shangl merged 1 commit into
GoogleChromeLabs:mainfrom
shangl:fix-symlink-loop
Sep 16, 2026
Merged

shangl merged 1 commit into
GoogleChromeLabs:mainfrom
shangl:fix-symlink-loop

Conversation

@shangl

@shangl shangl commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Prevent recursion loops from directory symlinks

addFilesRecursively() previously traversed directory structures using
fs.statSync(), which dereferences symbolic links. If a directory
symlink loop is present in the static directory (e.g. 'ln -s . loop'),
the recursive traversal runs indefinitely until Node.js throws an
ELOOP error, crashing the build process (CWE-674).

Use fs.lstatSync() to detect symbolic links and refuse to follow them,
preventing infinite recursion and build crashes.

Bug: b/530773570

@shangl
shangl requested a review from GrapeGreen September 16, 2026 14:33
addFilesRecursively() previously traversed directory structures using
fs.statSync(), which dereferences symbolic links. If a directory
symlink loop is present in the static directory (e.g. 'ln -s . loop'),
the recursive traversal runs indefinitely until Node.js throws an
ELOOP error, crashing the build process (CWE-674).

Use fs.lstatSync() to detect symbolic links and refuse to follow them,
preventing infinite recursion and build crashes.

Bug: https://b.corp.google.com/issues/530773570
@shangl
shangl merged commit 18c0474 into GoogleChromeLabs:main Sep 16, 2026
20 checks passed
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