Summary
A Cross-Site Request Forgery (CSRF) weakness in andreimarcu linux-server allows attackers to coerce authenticated users' browsers into invoking the uploadPutHandler endpoint.
When combined with a vulnerable upload or execution pathway, this can result in arbitrary code execution on the server whenever a victim visits a malicious page while logged in.
Affected context
The vulnerability arises in deployments of andreimarcu linux-server that expose the uploadPutHandler functionality to authenticated users and rely on browser-based sessions or cookies.
It becomes significant in environments where uploaded content can be processed or executed by the server, and where requests lack robust CSRF defenses such as per-request tokens or same-site protections.
Installations that integrate linux-server into administrative or automation workflows, especially through web interfaces, are more exposed if users frequently browse untrusted sites while authenticated.
Exploit preconditions
- Attack surface: Web interface endpoints that accept state-changing or upload requests, specifically the uploadPutHandler.
- Required access: Ability to get an authenticated user of linux-server to visit a malicious webpage or click a crafted link while logged in.
- Trigger point: The victim's browser automatically sends an HTTP request (e.g., PUT/POST) to uploadPutHandler using stored authentication cookies or headers.
- Why exploitation is possible: The server does not sufficiently verify the request's origin or include unguessable CSRF tokens, allowing an attacker-controlled site to generate valid, state-changing requests on behalf of the user.
Why this happens
This issue is rooted in missing or ineffective CSRF protections on a sensitive upload endpoint.
Under CWE-352, Cross-Site Request Forgery occurs when an application relies solely on ambient authentication (cookies, HTTP auth) and fails to bind state-changing requests to a user-intended action using mechanisms like anti-CSRF tokens, strict origin checks, or same-site cookie policies.
In linux-server's uploadPutHandler, the server accepts authenticated upload or execution-related requests without verifying that they were initiated by the legitimate user from the expected application context.
Potential impact
- An attacker may trigger arbitrary uploads that the server could later execute as code or scripts.
- Malicious files could be placed in sensitive directories, potentially enabling remote code execution.
- Existing configuration or application data could be overwritten or corrupted via forged requests.
- Server integrity and availability can be affected if uploads are used to install backdoors or disrupt services.
General mitigation guidance
Mitigation generally focuses on ensuring that state-changing endpoints cannot be invoked solely based on ambient authentication.
Recommended patterns include:
- Introducing per-request CSRF tokens bound to the user's session and validated on all upload and modification operations.
- Enforcing strict origin and referer checks for sensitive endpoints and rejecting requests from unexpected domains where appropriate.
- Using same-site cookies and minimizing reliance on cookies for high-risk operations, preferring explicit tokens or signed headers.
- Constraining what uploaded content can do by separating upload storage from executable paths and applying least-privilege execution policies.
- Requiring explicit user confirmation flows (e.g., POST-only forms with unique tokens) for operations that can modify server state or deploy code.
How teams detect issues like this
Detection typically relies on reviewing how authentication and session data are used in conjunction with state-changing routes.
Effective approaches include:
- Static analysis or linting rules that flag handlers performing uploads, configuration changes, or command execution that lack CSRF token validation or origin checks.
- Manual code review focusing on routes like uploadPutHandler to ensure all paths incorporate robust CSRF protections and do not accept cross-origin requests by default.
- Security testing using automated web scanners or custom scripts to send forged cross-origin requests and verify whether they are accepted without user interaction.
- Policy enforcement in development pipelines requiring CSRF protection patterns for any endpoint that writes to disk, alters configuration, or triggers execution.

