Sitelet https://github.com/dereuromark/cakephp-feedback/pull/18
Skip to content

Fix critical security vulnerabilities (RCE, Path Traversal, DoS) - #18

Merged
dereuromark merged 1 commit into
masterfrom
security-fixes
Nov 20, 2025
Merged

dereuromark merged 1 commit into
masterfrom
security-fixes

Conversation

@dereuromark

Copy link
Copy Markdown
Owner

Summary

This PR fixes critical security vulnerabilities that could lead to Remote Code Execution (RCE), path traversal, and Denial of Service (DoS) attacks.

🔴 CRITICAL Security Fixes:

  1. RCE via Unsafe Deserialization (Filesystem.php)

    • Issue: Used unserialize() without validation on filesystem data
    • Fix: Use unserialize($content, ['allowed_classes' => false]) to prevent object injection attacks
    • Impact: Prevents remote code execution
    • BC: Maintains backward compatibility with existing array-based serialized files
  2. Path Traversal Vulnerabilities (FeedbackController.php, Admin/FeedbackController.php)

    • Issue: User-supplied filenames concatenated directly to paths
    • Fix:
      • Validate file format with strict regex /^\d+-[a-f0-9]+\.feedback$/
      • Use realpath() to resolve paths and validate within allowed directory
      • Prevent ../ and other directory traversal attacks
    • Impact: Prevents unauthorized file access/deletion
  3. Screenshot DoS & Validation (FeedbackController.php)

    • Issue: No validation on base64-encoded screenshot data
    • Fix:
      • Validate base64 format with regex
      • Enforce 2MB size limit on encoded data
    • Impact: Prevents DoS via massive uploads and ensures data integrity

Test Plan

  • PHPCS code style checks pass
  • All fixes maintain backward compatibility
  • No breaking changes to existing functionality

🤖 Generated with Claude Code

@dereuromark
dereuromark force-pushed the security-fixes branch 3 times, most recently from 929950e to 1d44ea4 Compare November 20, 2025 21:53
This commit addresses critical security issues:

**CRITICAL:**
- Fix unsafe deserialization (RCE vulnerability) in Filesystem store
  - Use unserialize() with allowed_classes => false to prevent object injection
  - Maintains backward compatibility with existing array-based serialized files

- Fix path traversal vulnerabilities in file operations
  - Add strict file format validation with regex (alphanumeric session IDs)
  - Use realpath() to prevent directory traversal attacks
  - Validate files are within allowed directory

- Add screenshot validation to prevent abuse
  - Validate base64 format with regex for data URIs
  - Enforce 3MB size limit on encoded data
  - Allow non-URI values for backwards compatibility

All changes maintain backward compatibility while preventing RCE, path traversal, and DoS attacks.

All tests pass (21/21), PHPCS and PHPStan checks pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dereuromark
dereuromark merged commit fa7e98b into master Nov 20, 2025
16 checks passed
@dereuromark
dereuromark deleted the security-fixes branch November 20, 2025 21:57
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 67.50000% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.67%. Comparing base (8c678f3) to head (4fd03c4).
⚠️ Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
src/Controller/FeedbackController.php 50.00% 8 Missing ⚠️
src/Controller/Admin/FeedbackController.php 68.75% 5 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #18      +/-   ##
============================================
- Coverage     78.89%   77.67%   -1.23%     
- Complexity      136      156      +20     
============================================
  Files            11       11              
  Lines           398      430      +32     
============================================
+ Hits            314      334      +20     
- Misses           84       96      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants