Skip to content

test: fix defect path traversal tests - #50124

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
tniessen:test-fix-pm-traversal
Oct 16, 2023
Merged

test: fix defect path traversal tests#50124
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
tniessen:test-fix-pm-traversal

Conversation

@tniessen

Copy link
Copy Markdown
Member

The test never actually tested what it claims to test because it did not properly insert separators before ...

@tniessentniessen added permission Issues and PRs related to the Permission Model test Issues and PRs related to the tests. security Issues and PRs related to security. labels Oct 10, 2023
@nodejs-github-botnodejs-github-bot added the needs-ci PRs that need a full CI run. label Oct 10, 2023
@tniessentniessen added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 10, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 10, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@tniessentniessen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 11, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Trott
Trott previously approved these changes Oct 11, 2023
@Trott
Trott dismissed their stale reviewOctober 11, 2023 15:40

Actually, I'm not 100% sure I understand the motivation of the change and would rather wait for Rafael to weigh in

@tniessen

Copy link
Copy Markdown
MemberAuthor

I'm not 100% sure I understand the motivation of the change

The existing test seems to assume that

constallowedFolder=tmpdir.resolve('subdirectory/');

keeps the trailing /, however, tmpdir.resolve() simply uses path.resolve() internally, which discards trailing separators, so allowedFolder ends with subdirectory, not subdirectory/.

The other JavaScript file then constructs paths as follows:

consttraversalPath=allowedFolder+'../file.md';

Therefore, traversalPath ends with subdirectory../file.md, which is not a path traversal scenario. Adding a separator in front of .. solves this and should lead to an actual attempt at path traversal (i.e., subdirectory/../file.md).

The test never actually tested what it claims to test because it did not
properly insert separators before `..`.
@tniessen
tniessenforce-pushed the test-fix-pm-traversal branch from e159f6e to 953131aCompareOctober 15, 2023 13:42
@tniessen

Copy link
Copy Markdown
MemberAuthor

Rebased due to a conflict with f447a46.

@tniessen
tniessen requested review from RafaelGSS and removed request for RafaelGSSOctober 15, 2023 13:42
@RafaelGSSRafaelGSS added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 15, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 15, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@tniessentniessen added the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 16, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 16, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 0c56962 into nodejs:mainOct 16, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0c56962

targos pushed a commit that referenced this pull request Oct 23, 2023
The test never actually tested what it claims to test because it did not
properly insert separators before `..`.
PR-URL: #50124
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
@targostargos mentioned this pull request Oct 23, 2023
targos pushed a commit that referenced this pull request Nov 11, 2023
The test never actually tested what it claims to test because it did not
properly insert separators before `..`.
PR-URL: #50124
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
@targostargos mentioned this pull request Nov 12, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.permissionIssues and PRs related to the Permission ModelsecurityIssues and PRs related to security.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@tniessen@nodejs-github-bot@Trott@anonrig@Uzlopak@RafaelGSS