fix(api): reject persona ids that are not a single directory name - #3
Open
sergiobuilds wants to merge 1 commit into
Open
fix(api): reject persona ids that are not a single directory name#3sergiobuilds wants to merge 1 commit into
sergiobuilds wants to merge 1 commit into
Conversation
- `:id` was interpolated into `./personas/${id}/persona.md` unvalidated, so an encoded `..%2F..%2F` walked out of the personas directory and returned any `persona.md`, `nuance.md`, or `accounts.md` on the host with HTTP 200; the three `/personas/:id` routes now require `^[A-Za-z0-9._-]+$` and 404 on anything else
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.
:idgoes straight into the path:Nothing validates it, so an encoded
..%2Fwalks out ofpersonas/.Measured
Planted a file outside the personas directory, then asked for it through the API:
All three
/personas/:idroutes answered 200 the same way, including/qa-simulation.Reach is bounded — the filenames are hardcoded, so it only ever returns a
persona.md,nuance.md, oraccounts.md. That bound is a property of today's code, not a check, and it disappears the first time a filename becomes dynamic.After
/personas/testuser/personas/..%2F..%2Foutside%2Fsecret/qa-simulation/interview-logA persona id names one directory under
personas/, so the guard says exactly that:^[A-Za-z0-9._-]+$, with.and..excluded. It sits next to the id in each of the three routes rather than in middleware, so the constraint is visible where the value is read.