Summary
Terrapack's web-facing components contain an unrestricted file upload vulnerability that allows attackers to upload and execute arbitrary code on the server.
When exposed to untrusted clients, these endpoints can be abused to place executable payloads on the system and trigger remote code execution under the web server's privileges.
Affected context
This vulnerability affects Terrapack deployments using the following components in web-accessible environments:
- Terrapack TkWebCoreNG 1.0.20200914
- Terrapack TKServerCGI 2.5.4.150
- Terrapack TpkWebGIS Client 1.0.0
The risk is present where these components expose upload or import functionality over HTTP/S without strong server-side validation of file type, content, and storage location.
Installations that place these services on networks reachable by untrusted users or the public internet are more susceptible to exploitation.
Exploit preconditions
- Attack surface: HTTP/S endpoints or forms providing file upload or import functionality in Terrapack TkWebCoreNG, TKServerCGI, or TpkWebGIS Client.
- Required access: Network access to the affected Terrapack web interface; in many deployments this may be unauthenticated or use weak access controls.
- Trigger point: Submission of a crafted file via an upload endpoint that accepts the file and stores it in a location where it can be interpreted or executed by the server.
- Why exploitation is possible: The application does not sufficiently restrict what file types or contents can be uploaded and fails to enforce safe storage semantics (e.g., placing files under non-executable locations or stripping dangerous content), enabling uploaded files to be processed as executable code.
Why this happens
The underlying issue maps to CWE-434: Unrestricted Upload of File with Dangerous Type.
The Terrapack web components accept user-supplied files without robust, server-side checks on:
- The effective file type (beyond client-side or extension-based checks)
- The presence of executable code or scripts
- The destination directory's execution capabilities
When uploaded content can be placed in paths that are later executed or interpreted by the server environment, an attacker can transform a simple upload action into remote code execution.
Architecturally, this reflects a design that treats file uploads as inherently trustworthy, rather than rigorously constraining how, where, and in what form user-controlled files are accepted and stored.
Potential impact
- Remote execution of arbitrary code under the web server or Terrapack service account.
- Installation of web shells or backdoors for persistent access.
- Unauthorized access to or modification of geospatial and application data managed by Terrapack.
- Use of the compromised server as a pivot point for lateral movement within the organization's network.
- Service disruption, data tampering, or complete system takeover depending on the server's privileges.
General mitigation guidance
Effective mitigation focuses on hardening the file upload pipeline and constraining how uploaded content is handled:
- Enforce strict server-side validation of file types using MIME-type inspection and, where appropriate, content "magic number" checks rather than relying on file extensions or client-side logic.
- Maintain a positive allowlist of permitted file types and reject all non-listed formats.
- Store uploaded files in non-web-accessible, non-executable directories and serve them (if needed) through controlled download handlers rather than direct file paths.
- Normalize filenames and remove or replace user-controlled path elements, disallowing any path traversal sequences or special characters.
- Apply least-privilege to the web server and Terrapack service accounts so they cannot write to directories that are executed by the application platform or OS.
- Introduce layered security controls such as web application firewalls (WAF) with rules specifically tuned for file upload abuse patterns.
How teams detect issues like this
Organizations can approach detection using both code-centric and operational techniques:
- Static analysis and code review:
- Look for upload handlers that write files directly to web-accessible directories or application directories.
- Flag logic that only checks file extensions, client-side validation, or unvalidated MIME types.
- Examine any dynamic file inclusion or execution paths that can reference user-uploaded content.
- Configuration and policy checks:
- Verify that upload directories are configured as non-executable in the web server and OS.
- Ensure policies require allowlisted file types and centralized validation routines.
- Runtime and log analysis:
- Monitor logs for unusual uploads (unexpected extensions, repeated attempts, large volumes).
- Detect execution of files from upload directories or strange script names originating from those paths.
- Automated tooling:
- Employ web vulnerability scanners and SAST/IAST tools configured to test file upload endpoints.
- Integrate security checks into CI/CD to prevent introduction of new unrestricted upload paths.

