CVE-2023-28115
📋 TL;DR
CVE-2023-28115 is a PHAR deserialization vulnerability in the Snappy PHP library that allows attackers to achieve remote code execution by uploading malicious files and using the phar:// protocol. This affects all Snappy users prior to version 1.4.2, particularly when used with frameworks like Laravel or Symfony that have documented POP chains. The vulnerability occurs when user-controlled input is passed to the file_exists() function without proper protocol validation.
💻 Affected Systems
- KnpLabs/snappy
📦 What is this software?
Snappy by Knplabs
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution with full system compromise, allowing attackers to execute arbitrary commands, steal data, install malware, or pivot to other systems.
Likely Case
Remote code execution leading to web server compromise, data exfiltration, and potential lateral movement within the network.
If Mitigated
Denial of service or limited information disclosure if proper input validation and file upload restrictions are in place.
🎯 Exploit Status
Exploitation requires file upload capability and knowledge of vulnerable POP chains. The vulnerability is well-documented with public proof-of-concept references.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 1.4.2
Vendor Advisory: https://github.com/KnpLabs/snappy/releases/tag/v1.4.2
Restart Required: No
Instructions:
1. Update Snappy to version 1.4.2 or later using composer: composer require knplabs/knp-snappy:^1.4.2
2. Verify the update completed successfully
3. Test functionality to ensure no breaking changes
🔧 Temporary Workarounds
Input Validation and Protocol Restriction
allImplement strict input validation to reject phar:// protocol and other dangerous protocols in user-controlled input
Implement input validation in application code to filter out phar://, file://, and other dangerous protocols
File Upload Restrictions
allRestrict file uploads to safe locations and validate file types before processing
Configure web server to restrict upload directories and implement MIME type validation
🧯 If You Can't Patch
- Implement strict input validation to reject phar:// protocol in all user-controlled parameters
- Restrict file upload functionality and implement proper file type validation
🔍 How to Verify
Check if Vulnerable:
Check composer.json or installed packages for Snappy version <1.4.2
Check Version:
composer show knplabs/knp-snappy | grep versions
Verify Fix Applied:
Verify Snappy version is 1.4.2 or higher using composer show knplabs/knp-snappy
📡 Detection & Monitoring
Log Indicators:
- Unusual file uploads with .phar extensions
- Requests containing phar:// protocol in parameters
- Unexpected PHP object instantiation in logs
Network Indicators:
- Unusual outbound connections from web server
- Large data exfiltration from server
SIEM Query:
source="web_logs" AND (phar:// OR .phar) AND (generateFromHtml OR file_exists)
🔗 References
- https://github.com/KnpLabs/snappy/blob/5126fb5b335ec929a226314d40cd8dad497c3d67/src/Knp/Snappy/AbstractGenerator.php#L670
- https://github.com/KnpLabs/snappy/commit/1ee6360cbdbea5d09705909a150df7963a88efd6
- https://github.com/KnpLabs/snappy/commit/b66f79334421c26d9c244427963fa2d92980b5d3
- https://github.com/KnpLabs/snappy/pull/469
- https://github.com/KnpLabs/snappy/releases/tag/v1.4.2
- https://github.com/KnpLabs/snappy/security/advisories/GHSA-gq6w-q6wh-jggc
- https://github.com/KnpLabs/snappy/blob/5126fb5b335ec929a226314d40cd8dad497c3d67/src/Knp/Snappy/AbstractGenerator.php#L670
- https://github.com/KnpLabs/snappy/commit/1ee6360cbdbea5d09705909a150df7963a88efd6
- https://github.com/KnpLabs/snappy/commit/b66f79334421c26d9c244427963fa2d92980b5d3
- https://github.com/KnpLabs/snappy/pull/469
- https://github.com/KnpLabs/snappy/releases/tag/v1.4.2
- https://github.com/KnpLabs/snappy/security/advisories/GHSA-gq6w-q6wh-jggc