Skip to content

feat: prevent php session files to be uploaded#4412

Merged
fzipi merged 9 commits into
mainfrom
feat/lfi-php-session-file
Jan 23, 2026
Merged

feat: prevent php session files to be uploaded#4412
fzipi merged 9 commits into
mainfrom
feat/lfi-php-session-file

Conversation

@fzipi
Copy link
Copy Markdown
Member

@fzipi fzipi commented Jan 19, 2026

what

  • prevent simple file uploads of files that resemble PHP session file names

why

  • PHP session deserialization attacks

refs

Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
@fzipi fzipi added the release:new-detection In this PR we introduce a new detection label Jan 19, 2026
@fzipi fzipi requested review from a team and Copilot January 19, 2026 12:29
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

📊 Quantitative test results for language: eng, year: 2023, size: 10K, paranoia level: 1:
🚀 Quantitative testing did not detect new false positives

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds protection against PHP session file upload attacks to prevent PHP session deserialization vulnerabilities, specifically addressing CVE-2025-54236 (Magento Session Reaper).

Changes:

  • Adds new rule 933220 at paranoia level 2 to detect and block uploads of files matching PHP session naming patterns (sess_<session_id>)
  • Includes comprehensive test coverage with 17 test cases covering various attack vectors and legitimate filenames
  • Creates regex assembly file with pattern documentation for the session file detection

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
rules/REQUEST-933-APPLICATION-ATTACK-PHP.conf Implements rule 933220 to detect PHP session file uploads via FILES, FILES_NAMES, and custom filename headers (X-Filename, X_Filename, X.Filename, X-File-Name)
regex-assembly/933220.ra Defines the regex pattern assembly for detecting sess_ prefix followed by valid PHP session ID characters (20-256 chars)
tests/regression/tests/REQUEST-933-APPLICATION-ATTACK-PHP/933220.yaml Provides comprehensive test coverage with 17 test cases including multipart uploads, various headers, path variations, and negative test cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread regex-assembly/933220.ra Outdated
Comment thread rules/REQUEST-933-APPLICATION-ATTACK-PHP.conf Outdated
Comment thread rules/REQUEST-933-APPLICATION-ATTACK-PHP.conf Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread rules/REQUEST-933-APPLICATION-ATTACK-PHP.conf Outdated
@fzipi
Copy link
Copy Markdown
Member Author

fzipi commented Jan 19, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 19, 2026

@fzipi I've opened a new pull request, #4415, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits January 19, 2026 16:36
…4415)

* Initial plan

* Add test cases for comma and uppercase handling

Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Comment thread tests/regression/nginx-overrides.yaml
@fzipi fzipi requested a review from Xhoenix January 23, 2026 12:43
@fzipi fzipi enabled auto-merge January 23, 2026 12:43
@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 23, 2026

Why PL2? Looks it can goes into PL1.

@touchweb-vincent
Copy link
Copy Markdown
Contributor

Thank you very much for this PR, Felipe. I agree with @azurit - this rule should be in PL1.

Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
@fzipi
Copy link
Copy Markdown
Member Author

fzipi commented Jan 23, 2026

Moved to PL1!

@fzipi fzipi requested a review from azurit January 23, 2026 17:20
@fzipi fzipi added this pull request to the merge queue Jan 23, 2026
Merged via the queue into main with commit 2ff50be Jan 23, 2026
8 checks passed
@fzipi fzipi deleted the feat/lfi-php-session-file branch January 23, 2026 17:26
@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 23, 2026

@fzipi Thank you, great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:new-detection In this PR we introduce a new detection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants