An upload endpoint takes a certificate and the id of the app it belongs to, then replaces that app's cert. It trusts the id in the body because you cleared the role check.
What goes wrong
The endpoint reads a certificate and the identifiers of the application it targets, both from the request body, and calls the update operation. Authorization is a role check in the controller and nothing more.
Because the target application id travels in the body, the caller picks it. A user with the role can name an application that belongs to someone else and overwrite its trusted certificate. Every client that authenticates or validates that application is now working against material the attacker supplied.
The controller confirmed the caller is the kind of user allowed to upload certificates. It never confirmed the caller owns the application whose certificate is about to change. That second check is the one that matters here, and it is not present in the controller or, apparently, the service.
The pattern
@RequireRole('app-admin')
def uploadCert(req):
appId = req.applicationId # from the body
cert = req.certBytes
certs.replace(appId, cert) # any app, no owner check
return ok()@RequireRole('app-admin')
def uploadCert(req):
appId = req.applicationId
if not caller.owns(appId): # bind target to caller
deny()
cert = parseAndValidate(req.certBytes)
certs.replace(appId, cert)
audit(caller, 'cert-replace', appId)Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.
Why it matters to you
Replacing an application's certificate is a quiet way to break or subvert its authentication. Depending on how that cert is used, an attacker can knock the app offline, impersonate it, or position for interception, all from a routine-looking upload. The endpoint reads like plumbing, which is exactly why the missing ownership check survives review.
Whenever a write targets an object named in the request, authorize the object, not the action. The service is the right place for it, because that is the layer that cannot be bypassed by a second caller path into the same operation.
Check your own code
- Find writes whose target object id comes from the request body
- Verify the caller owns the target application before updating it
- Put the ownership check in the service, where a second path cannot skip it
- Audit certificate replacements with the acting user and target id