Sample report
Security report: example-app
This is a sample. The application, its code and the findings are invented. It shows what a CrimsonLock report contains and how much detail to expect.
Executive summary
We reviewed the source code of example-app’s backend API and found five vulnerabilities: one critical, two high, one medium and one low.
The most urgent is a live payment provider key stored in the repository (CL-01). Treat it as compromised and revoke it today: anyone who can read the repository, or has ever cloned it, can use it.
Two high-severity findings let one customer reach another customer’s data: a database query that can be manipulated (CL-02) and an export endpoint that never checks who is asking (CL-03).
None of the five needs a redesign. Each is a contained change, and a proposed fix is included with every finding.
What to fix first
- CL-01: revoke and replace the exposed key.
- CL-02 and CL-03: close the two ways into other customers’ data.
- CL-04: switch password reset tokens to a secure random source.
- CL-05: stop returning stack traces.
Findings at a glance
- CL-01 Critical Production API key committed to the repository Fix
- CL-02 High SQL injection in order lookup Fix
- CL-03 High Missing authorization check on export endpoint Fix
- CL-04 Medium Predictable password reset tokens Fix
- CL-05 Low Stack traces returned in error responses Fix
5 findingsSelect one to jump to it
Findings in detail
Production API key committed to the repository
config/payments.js:4
What we found
The live key for the payment provider is written directly into a source file. It has been there since the file was first committed, so it is also in the Git history.
Impact
Anyone who can read the repository can act as example-app towards the payment provider, for example to issue refunds or read customer payment records. That includes former contractors and every laptop or build server that holds a clone.
Proposed fix
- Revoke this key at the payment provider and issue a new one. Deleting it from the file is not enough, because it stays in the Git history.
- Load the new key from the environment or a secrets manager, never from source.
- Add secret scanning to your build pipeline, so a committed key is caught before it is merged.
SQL injection in order lookup
src/api/orders.js:40
What we found
The order ID from the query string is joined straight into a SQL statement. Nothing checks the value first, so the caller controls part of the query.
Impact
Anyone who can call this endpoint can read every order in the database by sending a crafted ID such as 1 OR 1=1. Because the statement is sent without parameters, a second statement can be appended to it, so orders can be changed or deleted as well.
Proposed fix
Pass the ID as a bound parameter. The database then treats it as a value and never as part of the statement.
Missing authorization check on export endpoint
src/api/export.js:18
What we found
The export endpoint checks that the caller is logged in, but not that the account in the URL is their own. The account ID is taken from the path and used as it is.
Impact
Any logged-in customer can download the complete order history of any other account by changing the number in the URL. Account IDs are sequential, so every account can be walked through one by one.
Proposed fix
Take the account from the logged-in session, not from the URL. After this change the account ID in the path is no longer used: either remove it from the route, or keep it and answer with “not found” when it does not match the session.
Predictable password reset tokens
src/auth/reset.js:12
What we found
Password reset tokens are generated with Math.random(), which is not a cryptographic random source. Its internal state can be reconstructed from a handful of observed values.
Impact
An attacker who requests a few reset tokens for an account they control can work out the generator’s state, predict the token issued for someone else’s reset, and take over that account. This takes skill and careful timing, which is why it is rated medium and not high.
Proposed fix
Generate tokens with Node’s built-in crypto module. Two related steps are worth doing in the same change: store only a hash of the token, and let it expire after a short time.
Stack traces returned in error responses
src/app.js:58
What we found
The global error handler sends the full error, including the stack trace, back to whoever made the request.
Impact
Stack traces reveal file paths, library versions and fragments of SQL. None of that is a breach on its own, but it tells an attacker exactly where to look, and it made CL-02 quicker to confirm.
Proposed fix
Log the error on the server and return a generic message. If support needs to match a user’s report to a log entry, add a request ID to both.
Remediation options
Your team can apply every fix in this report as written. If you would rather have CrimsonLock implement them, each finding is quoted separately and you choose which ones we take on.