Detailed Findings
F5
Critical SQL Injection (Authentication Bypass)
- Affected code
- routes/login.ts:34
- CWE
- CWE-89
Description
The login handler concatenates the submitted email address directly into the SQL statement,
allowing an attacker to alter the query's logic.
Business impact
Authentication can be bypassed entirely: an attacker can log in as an administrator without valid
credentials and access all customer and order data.
Root cause (code)
routes/login.ts:34 concatenates the email field as a string and does not use a parameterized
query (placeholder).
Steps to reproduce
- Send the request below.
- The server returns 200 and a valid authentication token.
- The token can be used as Authorization: Bearer to access administrative functionality.
Proof of Concept
POST /rest/user/login HTTP/1.1
Host: shop.example-inc.jp
Content-Type: application/json
{"email":"' OR 1=1--","password":"x"}
Remediation
Use parameterized queries (placeholders) or ORM binding, and never concatenate user input
into SQL statements. Also validate input and use a least-privilege database account.
F6
High NoSQL Injection
- Affected code
- routes/updateProductReviews.ts:17-19
- CWE
- CWE-943
Description
User input reaches a NoSQL query as an operator/object, changing the query semantics.
Business impact
Authentication bypass, data disclosure, and in $where contexts server-side code execution.
Root cause (code)
At routes/updateProductReviews.ts:17, { _id: req.body.id } is passed straight to update, and line 19 sets { multi: true }. Supplying an id of {"$ne":-1} matches every document, and no ownership check is performed.
Steps to reproduce
- Log in as an ordinary user and obtain a token.
- Send the request below, setting id to an operator object.
- Confirm that all reviews have been overwritten.
Proof of Concept
PATCH /rest/products/reviews HTTP/1.1
Host: shop.example-inc.jp
Authorization: Bearer <TOKEN>
Content-Type: application/json
{"id":{"$ne":-1},"message":"pwned"}
Remediation
Cast input to the expected type, reject objects/operators, and never build $where from user input.
F7
High Insecure Direct Object Reference (IDOR)
- Affected code
- routes/basket.ts:18
- CWE
- CWE-639
Description
An object is returned by its identifier without verifying it belongs to the current user.
Business impact
Unauthorized access to other users' data by enumerating identifiers.
Root cause (code)
routes/basket.ts retrieves the basket by the id from the URL with no ownership check (only authentication is required).
Steps to reproduce
- Log in as an ordinary user.
- Request an ID other than your own (/rest/basket/2).
- Another user's basket contents are returned.
Proof of Concept
GET /rest/basket/2 HTTP/1.1
Host: shop.example-inc.jp
Authorization: Bearer <TOKEN>
Remediation
Enforce object-level authorization: verify the resource owner matches the session user.
F8
High Broken Authentication
- Affected code
- routes/changePassword.ts:39
- CWE
- CWE-287
Description
Weaknesses in the authentication flow allow bypass or account takeover.
Business impact
Account takeover and unauthorized access to user functionality and data.
Root cause (code)
changePassword.ts validates the current password only inside the "if (currentPassword && ...)" branch, so validation is skipped when it is not provided.
Steps to reproduce
- With a valid session, send the request without the current parameter.
- The response confirms that the password has been changed.
- You can log in with the new password.
Proof of Concept
GET /rest/user/change-password?new=NewPass123&repeat=NewPass123 HTTP/1.1
Host: shop.example-inc.jp
Authorization: Bearer <TOKEN>
Remediation
Verify credentials server-side on every sensitive action, enforce MFA, and protect against CSRF.
F9
High Mass Assignment
- Affected code
- server.ts:382, models/user.ts:76-98
- CWE
- CWE-915
Description
The API binds request fields to the model without a whitelist, allowing privileged fields to be set.
Business impact
Privilege escalation (e.g. registering as an administrator) or tampering with protected attributes.
Root cause (code)
server.ts exposes POST /api/Users as a registration endpoint with no field filtering, and models/user.ts exposes role as a writable attribute whose validation permits 'admin'. As a result, a client-supplied role is accepted as-is.
Steps to reproduce
- As an anonymous user, send the request below with "role":"admin" in the request body.
- The account is created with administrator privileges.
- Log in with the newly created account — it has administrator privileges.
Proof of Concept
POST /api/Users HTTP/1.1
Host: shop.example-inc.jp
Content-Type: application/json
{"email":"attacker@evil.test","password":"x","role":"admin"}
Remediation
Bind only an explicit allowlist of fields; never accept role/privilege attributes from the client.
F10
Medium Sensitive Data Exposure — Directory Listing, Backups & Logs
- Affected code
- server.ts:288-289, server.ts:300-302, routes/logfileServer.ts:14
- CWE
- CWE-548
Description
Directory listing is enabled, exposing backup files and server logs that contain sensitive information. The exposure of source/configuration backups and access logs (tokens, IP addresses) significantly eases subsequent attacks.
Business impact
Exposed backup files and server logs may disclose sensitive information, including authentication tokens and source code, enabling unauthorized access and further attacks.
Root cause (code)
serveIndex is enabled on /ftp and /support/logs, and sensitive files are served by name.
Steps to reproduce
- Request /ftp to obtain a listing of the public directory.
- Request /support/logs/ to obtain a listing of the log files.
- Download a log file from the listing and inspect it for tokens and client IP addresses.
Proof of Concept
GET /ftp HTTP/1.1
Host: shop.example-inc.jp
GET /support/logs/ HTTP/1.1
Host: shop.example-inc.jp
Remediation
Disable directory listing, remove backups from the public area, and apply access control and rotation to logs.