If an applications uses the actual name or key of an object when generating web pages, and doesn't verify if the user is authorized for the target object, this can result in an insecure direct object reference flaw. An attacker can exploit such flaws by manipulating parameter values. Unless object references are unpredictable, it is easy for an attacker to access all available data of that type.
For example, the insure demo application uses userid as part of the url to access the allocations (/allocations/{id}). An attacker can manipulate id value and access other user's allocation information.
In
routes/allocations.js
, the insecure application takes user id from url to fetch the allocations.
var userId = req.params.userId; allocationsDAO.getByUserId(userId, function(error, allocations) { if (error) return next(error); return res.render("allocations", allocations); });
A safer alternative is to always retrieve allocations for logged in user (using
req.session.userId
)instead of taking it from url.