You are on page 1of 1

A1: BROKEN OBJECT LEVEL AUTHORIZATION

CHEAT SHEET

OWASP
API Security Top 10 Attacker substitutes ID of their resource in API call with an ID of a
resource belonging to another user. Lack of proper authorization
checks allows access. This attack is also known as IDOR (Insecure
Direct Object Reference).

USE CASES
• API call parameters use IDs of resourced accessed by the API
• /api/shop1/financial_details
• Attackers replace the IDs of their resources with a different,
which they guessed
• /api/shop2/financial_details
• The API does not check permissions and lets the call through

42CRUNCH.COM
• Problem is aggravated if IDs can be enumerated
• /api/123/financial_details

HOW TO PREVENT
• Implement authorization checks with user policies
and hierarchy
• Don’t rely on IDs sent from client. Use IDs stored in the session
A2: BROKEN AUTHENTICATION A3: EXCESSIVE DATA EXPOSURE object instead.
• Check authorization each time there is a client request to
access database
• Use random non-guessable IDs (UUIDs)

A4: LACK OF RESOURCES & RATE LIMITING

Poorly implemented API authentication allowing attackers to API exposing a lot more data than the client legitimately needs,
assume other users’ identities. relying on the client to do the filtering. Attacker goes directly to the
API and has it all.
USE CASES
• Unprotected APIs that are considered “internal” USE CASES
• Weak authentication not following industry best practices • APIs return full data objects as they are stored by the database
• Weak, not rotating API keys • Client application shows only the data that user needs to see
• Weak, plain text, encrypted, poorly hashed, shared/default • Attacker calls the API directly and gets sensitive data API is not protected against an excessive amount of calls or
passwords payload sizes. Attackers use that for DoS and brute force attacks.
• Susceptible to brute force attacks and credential stuffing HOW TO PREVENT
• Credentials and keys in URL • Never rely on client to filter data USE CASES
• Lack of access token validation (including JWT validation) • Review all responses and adapt responses to what the API • Attacker overloading the API
• Unsigned, weakly signed, non-expiring JWTs consumers really need • Excessive rate of requests
• Define schemas of all the API responses • Request or field sizes
HOW TO PREVENT • Don’t forget about error responses • “Zip bombs”
• Check all possible ways to authenticate to all APIs • Identify all the sensitive or PII info and justify its use
• Password reset APIs and one-time links also allow users to get • Enforce response checks to prevent accidental data and HOW TO PREVENT
authenticated and should be protected just as seriously exception leaks • Rate limiting
• Use standard authentication, token generation, password • Payload size limits
storage, MFA • Rate limits specific to API methods, clients, addresses
• Use short-lived access tokens • Checks on compression ratios
• Authenticate your apps (so you know who is talking to you) • Limits on container resources
A6: MASS ASSIGNMENT
• Use stricter rate-limiting for authentication, implement lockout
policies and weak password checks

A7: SECURITY MISCONFIGURATION


A5: BROKEN FUNCTION LEVEL AUTHORIZATION

USE CASES
• API working with the data structures
• Received payload is blindly transformed into an object
and stored
Poor configuration of the API servers allows attackers to exploit
NodeJS: them.
API relies on client to use user level or admin level APIs. Attacker var user = new User(req.body);
figures out the “hidden” admin API methods and invokes user.save(); USE CASES
them directly. • Unpatched systems
Rails: • Unprotected files and directories
USE CASES @user = User.new(params[:user]) • Unhardened images
• Some administrative functions are exposed as APIs • Missing, outdated, misconfigured TLS
• Non-privileged users can access these functions if they • Attackers can guess the fields by looking at the GET • Exposed storage or server management panels
know how request data • Missing CORS policy or security headers
• Can be a matter of knowing the URL, using a different • Error messages with stack traces
verb or parameter HOW TO PREVENT • Unnecessary features enabled
• Don’t automatically bind incoming data and internal objects
/api/users/v1/user/myinfo • Explicitly define all the parameters and payloads you HOW TO PREVENT
/api/admins/v1/users/all are expecting • Repeatable hardening and patching processes
• For object schemas, use the readOnly set to true for all • Automated process to locate configuration flaws
HOW TO PREVENT properties that can be retrieved via APIs but should never • Disable unnecessary features
• Don’t rely on app to enforce admin access be modified • Restrict administrative access
• Deny all access by default • Precisely define at design time the schemas, types, patterns • Define and enforce all outputs including errors
• Grant access based on specific roles you will accept in requests and enforce them at runtime
• Properly design and test authorization

A10: INSUFFICIENT LOGGING & MONITORING


A9: IMPROPER ASSETS MANAGEMENT
A8: INJECTION

Lack of proper logging, monitoring, and alerting let attacks go


Attacker finds non-production versions of the API: such as staging, unnoticed.
Attacker constructs API calls that include SQL-, NoSQL-, LDAP-, OS- testing, beta or earlier versions - that are not as well protected, and
and other commands that the API or backend behind it uses those to launch the attack. USE CASES
blindly executes. • Lack of logging, monitoring, alerting allow attackers to
USE CASES go unnoticed
USE CASES • DevOps, cloud, containers, K8S make having multiple • Logs are not protected for integrity
Attackers send malicious input to be forwarded to an internal deployments easy (Dev, Test, Branches, Staging, Old versions) • Logs are not integrated into Security Information and Event
interpreter: • Desire to maintain backward compatibility forces to leave old Management (SIEM) systems
• SQL APIs running • Logs and alerts are poorly designed
• NoSQL • Old or non-production versions are not properly maintained • Companies rely on manual rather than automated systems
• LDAP • These endpoints still have access to production data
• OS commands • Once authenticated with one endpoint, attacker may switch HOW TO PREVENT
• XML parsers to the other • Log failed attempts, denied access, input validation failures,
• Object-Relational Mapping (ORM) any failures in security policy checks
HOW TO PREVENT • Ensure that logs are formatted to be consumable by
HOW TO PREVENT • Inventory all API hosts other tools
• Never trust your API consumers, even if internal • Limit access to anything that should not be public • Protect logs as highly sensitive
• Strictly define all input data: schemas, types, string patterns - • Limit access to production data. Segregate access to • Include enough detail to identify attackers
and enforce them at runtime production and non-production data. • Avoid having sensitive data in logs - If you need the information
• Validate, filter, sanitize all incoming data • Implement additional external controls such as API firewalls for debugging purposes, redact it partially.
• Define, limit, and enforce API outputs to prevent • Properly retire old versions or backport security fixes • Integrate with SIEMs and other dashboards, monitoring,
data leaks • Implement strict authentication, redirects, CORS, etc. alerting tools

VS Code OpenAPI Extension API Security Info & News 42Crunch API Security Platform
http://bit.ly/42vscode APIsecurity.io 42Crunch.com

You might also like