Broken Access Control
Users can see or change data that is not theirs.
What it is
Access control decides who may do what. It is broken when the server trusts the client to ask only for its own data. Changing an id in the URL, calling an admin route directly, or skipping a check on one route is often enough.
What can happen
- Reading other users' data (for example, changing /orders/41 to /orders/42).
- Editing or deleting records that belong to someone else.
- Normal users reaching admin features.
Example: Fetching a record by id only
app.get("/scans/:id", async (req, res) => {
// Any logged-in user can read ANY scan by guessing its id.
const scan = await Scan.findById(req.params.id);
res.json({ scan });
});app.get("/scans/:id", requireAuth, async (req, res) => {
// The owner is part of the query, so other users' scans don't match.
const scan = await Scan.findOne({
_id: req.params.id,
userId: req.session.userId,
});
if (!scan) return res.status(404).json({ error: "Scan not found" });
res.json({ scan });
});Return the same 404 for "does not exist" and "not yours", so attackers can't learn which ids exist.
How to prevent it
- Deny by default: every route needs an explicit check.
- Put the owner (userId) inside the database query, not in an if after it.
- Check roles on the server. Hiding a button in the UI is not a check.
- Write a test that logs in as user B and tries to read user A's data.
What CrimsonScan checks
Partly detectedThe light scan finds open redirects and exposed admin or backup paths. Most access-control bugs need two logged-in users to test, which an outside URL scan cannot do.