Conversation
Sweep and repair dashboards listed directory names with readdirSync and then readFileSync, which follows symlinks. Ledger loading already rejects any symlink under the source root. A symlink named *.md or *.json on the state tree could be interpolated into README.md. Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
The dashboard renderer lists review markdown and run JSON with
readdirSyncplusreadFileSync. Those APIs follow symlinks. The action ledger walker already rejects any symlink under the source root. A*.mdor*.jsonsymlink on thestatetree can pull bytes from outside that tree into the published README.Evidence
Live
nodeimport ofmarkdownFilesandreadTexton the patched tree. A file symlink named1.mdpointing at a file outside the listing directory throws. A regular markdown file still lists.Real behavior proof
scripts/source.mjson branchfix/source-reject-symlinks.1.mdas a file symlink tosecret.mdoutside that directory. ImportedmarkdownFilesandreadTextfrom./scripts/source.mjswithnode --input-type=module. Then listed a directory that contains only a regular2.md.nodecommand (see Evidence). Both list and read printsource contains symlink. The regular file path is returned as a one-element array.readdirSync({ withFileTypes: true })pluslstatSyncreject the symlink beforereadFileSynccan follow it.statebranch inside GitHub Actions.Change
scripts/source.mjslists only regular files and throws on symbolic links formarkdownFiles,jsonFiles,readText, andreadJson.Origin
Introduced in
7964f2af5f7.