The contract uses a custom error code NOT_OWNER: u64 = 1
for permission checks, which causes the API to return HTTP 400 (Bad Request) instead of the semantically correct HTTP 403 (Permission Denied). This misleads API consumers into thinking the request format is incorrect when the actual issue is insufficient permissions.
The contract defines its own error constant:
And uses it for permission checks:
Likelihood: High - Occurs in every permission check
Impact: Low - Obscures permission violations.
Operational Impact:
Incorrect HTTP semantics: Returns 400 (Bad Request) instead of 403 (Permission Denied)
Misleading error responses: API consumers receive wrong error type - suggesting request format issues rather than permission issues
Replace the custom error code with the standard library's permission error:
Benefits of using standard errors:
Follows Aptos best practices
Documented HTTP error mapping: According to Aptos documentation, PERMISSION_DENIED
maps to HTTP 403, providing clear semantics for API consumers
According to the official Aptos error documentation, Move Standard Library errors have defined HTTP mappings:
Standard Error | HTTP Status | Meaning |
---|---|---|
PERMISSION_DENIED |
403 | The client does not have sufficient permission |
INVALID_ARGUMENT |
400 | Caller specified an invalid argument |
NOT_FOUND |
404 | A specified resource is not found |
Current behavior with custom NOT_OWNER: u64 = 1
:
Returns HTTP 400 (Bad Request)
Implies the request format or parameters are wrong
Expected behavior with error::permission_denied()
:
Returns HTTP 403 (Permission Denied) as documented
Clearly indicates a permission/authorization issue
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.