Summary
A Cross-Site Request Forgery (CSRF) flaw in the press.api.account.create_api_secret endpoint in Frappe Press allows state-changing operations to be triggered via a GET request without proper CSRF protections.
If an authenticated user visits a malicious web page, an attacker could cause unintended creation or rotation of API secrets on their account without their explicit consent.
Affected context
The vulnerability exists in deployments of the Frappe Press custom app that expose the press.api.account.create_api_secret endpoint.
The endpoint both writes to the database and is accessible via HTTP GET, making it easy to invoke through image tags, iframes, or other browser-initiated requests.
The risk materializes when users are authenticated to Frappe Press in their browser session and subsequently browse to attacker-controlled or compromised sites that can silently trigger this endpoint.
Exploit preconditions
- Attack surface: Web-facing HTTP endpoint
press.api.account.create_api_secret - Required access: Victim must be authenticated to the Frappe Press instance in their browser; attacker does not need direct access to the application
- Trigger point: A crafted link, image, script, or HTML element that causes the victim's browser to send a GET request to the vulnerable endpoint
- Why exploitation is possible: The endpoint performs state-changing operations over GET and relies on ambient browser credentials (cookies/session) without robust CSRF defenses, allowing cross-origin sites to initiate the request on behalf of the user
Why this happens
The core issue is a failure to enforce CSRF protections on a state-changing endpoint, combined with the use of the GET method for an operation that writes to the database.
This maps to CWE-352: Cross-Site Request Forgery, where a web application relies solely on browser-managed authentication (e.g., cookies) and does not validate that the request originated from a trusted user action or same-site context.
By allowing a side-effectful action (API secret creation) via GET without verification tokens or strict SameSite/session controls, the application implicitly trusts any authenticated browser request, including those initiated from attacker-controlled pages.
Potential impact
- Creation of unintended API secrets that an attacker may trick users into generating for later misuse
- Silent rotation or proliferation of API credentials, increasing the chance of accidental disclosure or mismanagement
- Loss of user control over their own API credential lifecycle and configuration
- Indirect facilitation of further abuse if generated secrets are exfiltrated through social engineering or other channels
General mitigation guidance
CSRF mitigation typically focuses on ensuring that state-changing operations require explicit, same-site user intent and are not triggerable by arbitrary cross-origin requests.
Recommended defensive patterns include:
- Restricting state-changing endpoints (such as API secret creation) to HTTP POST or other non-GET methods, following RESTful semantics
- Enforcing CSRF tokens or similar anti-forgery mechanisms on all authenticated, state-changing requests, with server-side validation
- Applying SameSite cookie attributes and considering additional session-binding mechanisms to reduce credential usage across untrusted origins
- Designing API secret management flows to require explicit user interaction and, where appropriate, re-authentication or step-up verification
- Centralizing authorization checks and CSRF enforcement at the framework/middleware layer to avoid per-endpoint gaps
These patterns help ensure that browser-initiated requests reflect genuine user actions rather than attacker-crafted cross-origin interactions.
How teams detect issues like this
CSRF-related issues are best identified through a combination of design review, automated checks, and targeted testing.
Possible detection strategies include:
- Static analysis rules or security linters that flag state-changing handlers exposed via GET or without CSRF decorators/middleware
- Framework-level configuration auditing to ensure all authenticated write endpoints are covered by CSRF protection mechanisms
- Code review practices that treat any "write to database" or "security-sensitive action" over GET as a red flag
- Application security testing (manual or automated) that attempts cross-origin invocation of sensitive endpoints from attacker-controlled pages
- Security policies in CI/CD that prevent merging of routes lacking proper HTTP verb usage and CSRF controls
Automated tools can augment manual review by systematically scanning for misconfigured routes and inconsistent enforcement of CSRF protections.

