OWASP
-
- Injection
- Broken Authentication
- Sensitive Data Exposure
- XML External Entities (XXE)
- Broken Access Control
- Security Misconfiguration
- Cross-Site Scripting (XSS)
- Insecure Deserialization
- Using Components with Known Vulnerabilities
- Insufficient Logging & Monitoring
Cross-Site Scripting (XSS)
CSRF
-
Symptom
A
CSRF
attack works because browser requests automatically include all cookies including session cookies. Therefore, if the user is authenticated to the site, the site cannot distinguish between legitimate authorized requests and forged authenticated requests. -
Treatment
-
CSRF
relies oncookies
to work. If the service doesn't usecookies
,CSRF
protection can be turned off. -
Resources
SSRF
Session Management
URL Rewriting
-
Pros
- Always work regardless of cookies settings
-
Cons
- not secure, as session ID is exposed in URL
- Only works for textual information
Cookies
Java
- Oracle - Secure Coding Guidelines for Java SE (opens in a new tab)
- SEI CERT Oracle Coding Standard for Java (opens in a new tab)
- OWASP - OWASP Secure Coding Practices-Quick Reference Guide (opens in a new tab)
HTTP Authentication
HTTP Basic
-
A request contains a header field in the form of
Authorization: Basic <credentials>
, wherecredentials
is theBase64
encoding of ID and password joined by a single colon:
-
Get encoded credentials
CREDENTIALS=$(echo -n <ID>:<Password> | base64)
-
Include in
HTTP
request withAuthorization
header:Authorization: Basic ${CREDENTIALS}
-
HTTP Digest Authentication
- Similar to
HTTP Basic
, but useMD5
instead ofBase64
.
Web
Permissions API
Content Security Policy (CSP)
-
Key points
- Prevents
XSS
attacks by whitelisting the sources of content that are allowed to be loaded on a page
- Prevents
-
Implementations
HTTP Strict Transport Security (HSTS)
-
Key points
-
Enforce the use of
HTTPS
to protect againstMan-in-the-Middle
attackse.g.
Strict-Transport-Security: max-age=3600
will tell the browser that forthe next hour (3600 seconds)
it should not interact with the applications with insecure protocols.When a user tries to access an application secured by
HSTS
throughHTTP
, the browser will simply refuse to go ahead, automatically convertinghttp://
URLs tohttps://
. -
Preloading domains that enforce
HSTS
in the browser to ensure the first interaction is secureBrowsers such as Chrome use a database to know if a website enforces
HSTS
. This database is called theHSTS Preload List
. This is to ensure even the first interaction between the browser and the website is secure.
-
-
Implementation
-
Resources
HTTP Strict Transport Security - OWASP Cheat Sheet Series (opens in a new tab)
HTTP Public Key Pinning (HPKP), Deprecated
-
Key points
Deprecated
, with all major browsers support removed due to complex implementation- Declare that a website's HTTPS certificate should only be treated as valid if the public key is contained in a list specified over HTTP to prevent MITM attacks that use valid CA-issued certificates.
- Prevents
Man-in-the-Middle
attacks by ensuring the browser only accepts a specific certificate for a domain - Ensure
trust on the first interaction
X-Frame-Options
-
Key points
- Replaced by
Content-Security-Policy Level 2
frame-ancestors
directive
- Replaced by
Feature Policy
-
Key points
- Defines a mechanism that allows developers to
selectively enable and disable use of various browser features and APIs
. - Replaced by
Permissions Policy
andDocument Policy
- Defines a mechanism that allows developers to
Referrer Policy
-
Key points
-
Control the
referrer
header sent by the browser to the serverno-referrer
- No referrer information is sentno-referrer-when-downgrade
- The referrer is sent only when the protocol security level stays the same (HTTP -> HTTP, HTTPS -> HTTPS)same-origin
- The referrer is sent only when the referring page is from the same origin as the requestorigin
- The referrer is sent only when the referring page is from the same origin as the request, without its pathstrict-origin
- The referrer is sent only when the referring page is from the same origin as the request, without its query stringorigin-when-cross-origin
- The referrer is sent only when the referring page is from the same origin as the request, without its path, but sent in full when the referring page is from a different originstrict-origin-when-cross-origin
- The referrer is sent only when the referring page is from the same origin as the request, without its query string, but sent in full when the referring page is from a different originunsafe-url
- The referrer is sent in full
-
-
Resources