Summary
Sourcecodester Covid-19 Contact Tracing System 1.0 contains an unrestricted file upload vulnerability in the user image handling functionality, allowing attackers to upload a PHP reverse shell instead of a benign image.
When the uploaded file is executed by the server, this can lead to full remote code execution under the web server context, especially in deployments that do not enforce strict file type validation and storage separation.
Affected context
This vulnerability occurs in deployments of Covid-19 Contact Tracing System 1.0 where user-submitted image uploads are accepted and stored in a web-accessible directory without robust validation.
The risk is highest when:
- The upload endpoint trusts client-provided file types or extensions
- The uploaded files are stored in a directory that the web server can execute (e.g., PHP-enabled folders)
- There is no secondary validation or filtering of file content before making files accessible
Exploit preconditions
- Attack surface: Public or internal web interface that allows users to upload profile images or similar media.
- Required access: Ability to reach the file upload functionality (e.g., authenticated user account or any role allowed to upload images).
- Trigger point: Uploading a crafted PHP file disguised as an image, followed by an HTTP request that directly accesses the uploaded file.
- Why exploitation is possible: The server-side code does not adequately restrict the file types, content, or storage location of uploaded files, allowing executable PHP code to be placed in a location where the web server will interpret and run it.
Why this happens
The core issue aligns with CWE-434: Unrestricted Upload of File with Dangerous Type.
The application treats user-uploaded files as benign images but fails to enforce strict checks on:
- File extension and MIME type
- Actual file content and structure
- Storage in non-executable locations
As a result, attacker-controlled files containing server-side code can be uploaded and later executed by accessing them via HTTP, turning a simple upload feature into a code execution primitive.
Potential impact
- Remote execution of arbitrary PHP code on the server
- Full compromise of the web application and its data
- Theft or modification of sensitive records (e.g., contact tracing data)
- Installation of web shells and persistence mechanisms
- Lateral movement to other systems reachable from the compromised host
- Use of the compromised server as a pivot for further attacks or malware distribution
General mitigation guidance
Effective mitigation focuses on hardening the entire file upload pipeline and limiting what uploaded content can do:
- Enforce strict whitelists of allowed file types (e.g., common image formats) using server-side checks on both extension and content signatures.
- Store uploads in directories that are not executable and are outside of the web root, serving them via controlled handlers rather than direct file execution.
- Normalize filenames and remove user-controlled path or extension elements to avoid bypasses.
- Strip or re-encode uploaded files (e.g., image re-processing) to remove embedded payloads and ensure only valid media content is preserved.
- Run the web server and associated services with least privilege to limit damage if a file is misclassified.
- Consider implementing centralized upload services or libraries that apply consistent security policies across all upload endpoints.
How teams detect issues like this
Detection typically combines code-level review with runtime monitoring:
- Static analysis and code review:
- Identify upload endpoints that move files directly into web-accessible directories.
- Look for missing or weak validation of file extensions, MIME types, and content.
- Flag any logic that allows PHP or other executable file types to be uploaded from untrusted sources.
- Configuration and policy checks:
- Verify that upload directories are configured as non-executable in web server settings.
- Enforce policies that disallow dynamic execution from user-controlled paths.
- Runtime monitoring:
- Monitor web server logs for access patterns to newly uploaded files or unexpected script locations.
- Use host-based intrusion detection to detect creation and execution of atypical PHP files in upload directories.
- Automated security scanning tools can help spot risky upload flows and misconfigurations as part of CI/CD or periodic assessments.

