- Injection. Injection flaws, such as SQL, NoSQL, OS, and LDAP injection, occur when untrusted data is sent to an interpreter as part of a command or query. The attacker's hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization.
- Broken Authentication. Application functions related to authentication and session management are often implemented incorrectly, allowing attackers to compromise passwords, keys, or session tokens, or to exploit other implementation flaws to assume other users' identities temporarily or permanently.
- Sensitive Data Exposure. Many web applications and APIs do not properly protect sensitive data, such as financial, healthcare, and PII. Attackers may steal or modify such weakly protected data to conduct credit card fraud, identity theft, or other crimes. Sensitive data may be compromised without extra protection, such as encryption at rest or in transit, and requires special precautions when exchanged with the browser.
- XML External Entities (XXE). Many older or poorly configured XML processors evaluate external entity references within XML documents. External entities can be used to disclose internal files using the file URI handler, internal file shares, internal port scanning, remote code execution, and denial of service attacks.
- Broken Access Control. Restrictions on what authenticated users are allowed to do are often not properly enforced. Attackers can exploit these flaws to access unauthorized functionality and/or data, such as access other users' accounts, view sensitive files, modify other users' data, change access rights, etc.
- Security Misconfiguration. Security misconfiguration is the most commonly seen issue. This is commonly a result of insecure default configurations, incomplete or ad hoc configurations, open cloud storage, misconfigured HTTP headers, and verbose error messages containing sensitive information. Not only must all operating systems, frameworks, libraries, and applications be securely configured, but they must be patched/upgraded in a timely fashion.
- Cross-Site Scripting XSS. XSS flaws occur whenever an application includes untrusted data in a new web page without proper validation or escaping, or updates an existing web page with user-supplied data using a browser API that can create HTML or JavaScript. XSS allows attackers to execute scripts in the victim's browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites.
- Insecure Deserialization. Insecure deserialization often leads to remote code execution. Even if deserialization flaws do not result in remote code execution, they can be used to perform attacks, including replay attacks, injection attacks, and privilege escalation attacks.
- Using Components with Known Vulnerabilities. Components, such as libraries, frameworks, and other software modules, run with the same privileges as the application. If a vulnerable component is exploited, such an attack can facilitate serious data loss or server takeover. Applications and APIs using components with known vulnerabilities may undermine application defenses and enable various attacks and impacts.
- Insufficient Logging & Monitoring. Insufficient logging and monitoring, coupled with missing or ineffective integration with incident response, allows attackers to further attack systems, maintain persistence, pivot to more systems, and tamper, extract, or destroy data. Most breach studies show time to detect a breach is over 200 days, typically detected by external parties rather than internal processes or monitoring.
Blog about knowledge sharing and key points about tech concepts.
Search This Blog
Monday, August 3, 2020
Top 10 Web Application Security Risks
API Security Checklist Points
Checklist of the most important security countermeasures when designing, testing, and releasing your API.
Authentication
- Don't use
Basic Auth
. Use standard authentication instead (e.g. JWT, OAuth). - Don't reinvent the wheel in
Authentication
,token generation
,password storage
. Use the standards. - Use
Max Retry
and jail features in Login. - Use encryption on all sensitive data.
JWT (JSON Web Token)
- Use a random complicated key (
JWT Secret
) to make brute forcing the token very hard. - Don't extract the algorithm from the header. Force the algorithm in the backend (
HS256
orRS256
). - Make token expiration (
TTL
,RTTL
) as short as possible. - Don't store sensitive data in the JWT payload, it can be decoded easily.
OAuth
- Always validate
redirect_uri
server-side to allow only whitelisted URLs. - Always try to exchange for code and not tokens (don't allow
response_type=token
). - Use
state
parameter with a random hash to prevent CSRF on the OAuth authentication process. - Define the default scope, and validate scope parameters for each application.
Access
- Limit requests (Throttling) to avoid DDoS / brute-force attacks.
- Use HTTPS on server side to avoid MITM (Man in the Middle Attack).
- Use
HSTS
header with SSL to avoid SSL Strip attack.
Input
- Use the proper HTTP method according to the operation:
GET (read)
,POST (create)
,PUT/PATCH (replace/update)
, andDELETE (to delete a record)
, and respond with405 Method Not Allowed
if the requested method isn't appropriate for the requested resource. - Validate
content-type
on request Accept header (Content Negotiation) to allow only your supported format (e.g.application/xml
,application/json
, etc.) and respond with406 Not Acceptable
response if not matched. - Validate
content-type
of posted data as you accept (e.g.application/x-www-form-urlencoded
,multipart/form-data
,application/json
, etc.). - Validate user input to avoid common vulnerabilities (e.g.
XSS
,SQL-Injection
,Remote Code Execution
, etc.). - Don't use any sensitive data (
credentials
,Passwords
,security tokens
, orAPI keys
) in the URL, but use standard Authorization header. - Use an API Gateway service to enable caching, Rate Limit policies (e.g.
Quota
,Spike Arrest
, orConcurrent Rate Limit
) and deploy APIs resources dynamically.
Processing
- Check if all the endpoints are protected behind authentication to avoid broken authentication process.
- User own resource ID should be avoided. Use
/me/orders
instead of/user/654321/orders
. - Don't auto-increment IDs. Use
UUID
instead. - If you are parsing XML files, make sure entity parsing is not enabled to avoid
XXE
(XML external entity attack). - If you are parsing XML files, make sure entity expansion is not enabled to avoid
Billion Laughs/XML bomb
via exponential entity expansion attack. - Use a CDN for file uploads.
- If you are dealing with huge amount of data, use Workers and Queues to process as much as possible in background and return response fast to avoid HTTP Blocking.
- Do not forget to turn the DEBUG mode OFF.
Output
- Send
X-Content-Type-Options: nosniff
header. - Send
X-Frame-Options: deny
header. - Send
Content-Security-Policy: default-src 'none'
header. - Remove fingerprinting headers -
X-Powered-By
,Server
,X-AspNet-Version
, etc. - Force
content-type
for your response. If you returnapplication/json
, then yourcontent-type
response isapplication/json
. - Don't return sensitive data like
credentials
,Passwords
, orsecurity tokens
. - Return the proper status code according to the operation completed. (e.g.
200 OK
,400 Bad Request
,401 Unauthorized
,405 Method Not Allowed
, etc.).
CI & CD
- Audit your design and implementation with unit/integration tests coverage.
- Use a code review process and disregard self-approval.
- Ensure that all components of your services are statically scanned by AV software before pushing to production, including vendor libraries and other dependencies.
- Design a rollback solution for deployments.
Subscribe to:
Posts (Atom)