Supply Chain - Historical Sensitive Data Scan API Returns 401 or 403
Overview
The Historical Sensitive Data Scan API starts a scan of historical commits in a code repository. On Aqua SaaS, the call returns HTTP 403 or HTTP 401 when the bearer token’s endpoint scope is too narrow or the API key has no Aqua role assigned. Token generation can still succeed in both cases.
This article explains those two authorization failures, the token scope and role settings that clear them, and how to confirm the scan request is accepted.
Understanding the Historical Sensitive Data Scan API
The API scans one code repository for sensitive data in historical commits. Call it on the regional Aqua SaaS edge host:
POST https://<region>.edge.cloud.aquasec.com/supply_chain/v2/build/bleed/scansRequest body:
{
"repository_id": "<repository-uuid>"
}For Eg: an Asia-1 tenant, the edge host is:
https://ap-southeast-1.edge.cloud.aquasec.comUse the edge host for the region where the tenant runs. HTTP 401 or HTTP 403 from that host means the request reached the API. The host and path are valid; the API key role or the bearer token scope is what denied the call.
Authentication uses a bearer token created from an API key. Two controls apply independently:
API key role — the key must have an Aqua role. A key with no role cannot perform this action.
Token
allowed_endpoints— the bearer token can call only the endpoints named when the token is created. A narrow list does not include this Supply Chain API. Create the token withANY:*.
Updating the token script does not change a token that was already issued. Generate a new bearer token after assigning the role and after setting allowed_endpoints to ANY:*.
Symptoms
POST /v2/tokens succeeds, then the historical scan request fails with one of these responses.
Restricted token scope (HTTP 403):
User is not authorized to access this resource with an explicit deny in an identity-based policy.API key with no role (HTTP 401):
{
"code": 401,
"message": "Not authorized to perform this action."
}Enabling individual permission options on the API key does not clear either error when the token scope is restricted or no role is assigned.
Solution
Apply both settings. Leaving either one unchanged leaves the scan call unauthorized.
1. Assign a role to the API key
HTTP 401 Not authorized to perform this action is returned when the API key has no Aqua role.
In the Aqua Console, open API Keys.
On the key used for this API, select Edit.
Assign an Aqua role in the role field. Use a role that can access Supply Chain code repositories. Leave the role field empty and the key stays unauthorized.
Save the API key.
2. Issue a bearer token with allowed_endpoints set to ANY:*
HTTP 403 with an explicit deny in an identity-based policy is returned when the bearer token was created with a restricted allowed_endpoints list.
Set the token request body to:
POST_BODY='{"validity":240,"allowed_endpoints":["ANY:*"]}'validity is the token lifetime in minutes. ANY:* allows the token to call this Supply Chain endpoint.
That body is part of the signed request. Rebuild the string to sign so it includes the updated body, then create a new token:
STRING_TO_SIGN="$TIMESTAMP$METHOD/v2/tokens$POST_BODY"Sign STRING_TO_SIGN with the API secret, send it with the API key to POST /v2/tokens, and keep only the bearer token returned by that call. Tokens created before this change keep the previous endpoint scope.
3. Start the historical scan
curl -sS -X POST \
'https://ap-southeast-1.edge.cloud.aquasec.com/supply_chain/v2/build/bleed/scans' \
-H 'Authorization: Bearer <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"repository_id":"<repository-uuid>"}'Replace the host with the edge host for the tenant region. Replace <repository-uuid> with the code repository ID. Use the bearer token from step 2.
A successful call returns HTTP 200 and a scan record:
{
"data": [
{
"scan_id": "<scan-id>",
"status": 0
}
]
}Verification
Edit the API key and confirm a role is selected, then save.
Generate a new bearer token with
allowed_endpointsset to["ANY:*"].Send
POST /supply_chain/v2/build/bleed/scanswith that token and a validrepository_id.Confirm HTTP 200 and a
scan_idindata.Confirm the HTTP 403 identity-policy deny, and the HTTP 401
Not authorized to perform this actionresponse no longer occur.
Important Considerations
New token required
Updating the generation script does not expand a bearer token that already exists. Call the scan API with a token created after the ANY:* change.
Role and scope are separate
A role on the API key does not widen allowed_endpoints. ANY:* on the token does not replace a missing role. Both are required.
Signature must match the body
If POST_BODY changes and the signature is still computed from the previous body, token generation does not apply the new scope. Recompute STRING_TO_SIGN from the updated POST_BODY before requesting the token.
Regional host
Call the edge host for the tenant region. Asia-1 uses ap-southeast-1.edge.cloud.aquasec.com. The same API path on another region’s edge host belongs to that region.
Platform Coverage
Component: Server API (Supply Chain)
Platform: Aqua SaaS
Regions: Regional edge hosts. Eg: Asia-1 uses
ap-southeast-1.edge.cloud.aquasec.comAPI: Historical sensitive data scan (
POST /supply_chain/v2/build/bleed/scans)
Related Resources
Did you find it helpful? Yes No
Send feedback