Skip to content

fix(waf): reject a trailing line break in deny paths - #451

Open
Crackhead-gsk wants to merge 1 commit into
MythicalLTD:developfrom
Crackhead-gsk:fix/waf-path-pattern-trailing-newline
Open

Crackhead-gsk wants to merge 1 commit into
MythicalLTD:developfrom
Crackhead-gsk:fix/waf-path-pattern-trailing-newline

Conversation

@Crackhead-gsk

Copy link
Copy Markdown
Contributor

What

WebSpaceWafRules::isValidPath() accepts a path with a trailing line break (for example /a followed by a newline).

Cause

PATH_PATTERN ends in $ without the D (dollar-end-only) modifier. In PCRE, $ also matches right before a final newline, so "/a\n" passes the check. The class exists to make sure only plain paths end up in the generated reverse proxy configuration, and a newline in a value starts a new config line there.

isValidIp() is not affected: its first check rejects every character outside 0-9 A-F a-f : . /, which includes line breaks.

Fix

Add the D modifier to PATH_PATTERN (the only place it is used). Nothing else changes.

Tests

backend/tests/Helpers/WebSpaceWafRulesTest.php (4 tests, 36 assertions): ordinary paths still pass, trailing/inner line breaks are rejected, unsafe paths (traversal, .well-known, quotes, braces, over-length) are rejected, and the IP check rejects line breaks and bad prefixes.

PHPUnit 11 against this branch: OK. Against current develop the line-break test fails on "/a\n" and the other three pass, so only the reported behaviour changes.

Verified / not verified

  • Verified: the tests above and php -l.
  • Not verified: I did not boot a panel from develop, and the generated proxy config was not inspected; the change only tightens input validation.

PATH_PATTERN ended in $ without the D modifier, so a value such as "/a\n"
passed isValidPath(). The value is written into generated reverse proxy
configuration, where a newline starts a new line. Add the D modifier and test
line breaks, unsafe paths and the IP check.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3faf369 and 1785cb5.

Files selected for processing: 2
  • backend/app/Helpers/WebSpaceWafRules.php
  • backend/tests/Helpers/WebSpaceWafRulesTest.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

This branch has not been deployed

No deployments
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.

1 participant