HTTP security headers
How a site asks the browser to protect itself with CSP, HSTS, X-Frame-Options and CORS, and what an employee can observe.
On this page
In 30 seconds
- Where it happens
- On any web page, whether public, internal or supplied by a partner.
- What the attacker wants
- To run a script in the page (the CSP limits the allowed content sources[2]), to intercept a connection that goes over HTTP (HSTS forces HTTPS[3]) or to hide the page under a booby-trapped frame (X-Frame-Options and frame-ancestors oppose this[4]).
- The reflex
- Faced with a certificate warning or a page that behaves unexpectedly, do not click past it, stop and notify the web team or security.
- If it's already done
- If you accepted a certificate exception or typed a password on a doubtful page, notify security without delay and change the password concerned.
What it is
When a site sends a page, it attaches lines of settings to it, the HTTP response headers. The browser reads them and follows them. According to OWASP, these headers are easy to put in place and can help prevent flaws such as cross-site scripting, clickjacking and information disclosure[1].
An employee configures nothing: these rules are set on the server side and are the web team's job. It is enough to know what they do, to understand why a browser sometimes refuses to open a page, and to recognize behavior worth reporting.
Straight answers
What is a security header?
It is a line the server adds to its response to give an instruction to the browser. Most often, it restricts what the page is allowed to do. The OWASP Secure Headers project describes these headers as settings which, once in place, can keep modern browsers from falling into easily avoidable vulnerabilities[5].
What does the CSP do?
The Content Security Policy (CSP) states the origin of the content a page is allowed to load[1]. It can stop the page from running scripts written in its own code, from loading scripts from arbitrary servers, from calling the eval function, from submitting forms to another site or from embedding objects, which blocks, for example, a fake login form injected into the page[2].
It does not remove flaws: OWASP presents it as a second layer of protection, which makes a flaw much harder to exploit, and states that it must not be the only defense against XSS[2].
What does HSTS do?
Once a compatible browser has received this header, it no longer sends anything over HTTP to the domain concerned and switches everything to HTTPS. It also removes the screens that offer to continue despite an invalid certificate[3]. This is what protects the person who types an address without the HTTPS padlock or who opens an old bookmark: an attacker on the path cannot count on an acceptance click[3].
What does X-Frame-Options do?
It states whether the page may be displayed in a frame (frame, iframe, embed or object) of another site[1]. The issue is clickjacking: the attacker stacks transparent or opaque layers so that the victim clicks a button on another page while believing they are clicking on their own[6]. The example OWASP gives is a "click here for a free iPod" button placed exactly above a "delete all messages" button of a mail service loaded in an invisible frame[6]. Keystrokes can be hijacked in the same way[6].
OWASP states that the CSP frame-ancestors directive makes X-Frame-Options obsolete for the browsers that support it[1].
What does CORS do?
By default, a browser applies the same-origin policy: a page cannot read the data of another domain[7]. Two addresses have the same origin if their scheme, host and port are identical[7]. CORS lets a server relax this rule for the sites it names. For Microsoft, CORS is not a security feature, it relaxes security, and an API is not safer for allowing CORS[7].
What can an employee observe?
Little, and that is normal. HSTS has a visible effect: the browser no longer offers to bypass an invalid certificate[3]. If an internal site or a partner tool lets you "continue anyway" on a certificate warning, or if a page shows a padlock but behaves abnormally, report it as it is to the web team. Diagnosing the headers is not your task.
How it works
The server can send the CSP in a response header, the preferred form, which gives access to all its functions, including in every response and not only the home page[2]. A variant, Content-Security-Policy-Report-Only, blocks nothing and sends violation reports: it is often used as a first step before blocking mode[2]. A meta tag is possible when the headers are outside the team's control, but it does not allow protection against display in a frame[2].
For HSTS, the validity period is set in seconds. OWASP gives the example of 63072000 seconds, which is two years, and an example of 86400 seconds for an initial deployment where mistakes are possible[3]. The preload list of the Chrome browser, picked up by Firefox and Safari, lets a domain be registered, with its owner's agreement[3].
These settings can also be applied somewhere other than in the application. For X-Frame-Options, OWASP cites adding it through a filter or at the level of a web application firewall[4]. Such a firewall (WAF) protects centrally against common attacks and makes it possible to fix a known flaw in one place rather than in each application[8].
What you do
Your part comes down to a few gestures.
- Do not click past a certificate warning. The scenario OWASP describes is that of an attacker who presents an invalid certificate hoping the user will accept it[3].
- Do not type a password on a page that seems strange to you, even with a padlock.
- Report to the web team or to security any unexpected behavior: a page that displays inside a frame, a confirmation request that matches none of your actions, a login form that appears while you are browsing.
- On the web team's side, checking is done with audit tools. OWASP cites Mozilla Observatory, which checks a site's headers, and SmartScanner, which scans the whole site whereas online tools generally test the home page[1].
Pitfalls
- CORS open to everyone. OWASP recommends naming specific origins rather than the * wildcard. It admits that the wildcard may be necessary, for example for a public API reachable from anywhere[1].
- A CSP that is too permissive. The value 'unsafe-inline' allows scripts and styles written in the page[2]. OWASP warns that a non-strict policy that is too detailed or too permissive likely leads to bypasses and a loss of protection[2].
- HSTS badly dosed. With a very long duration, an expired or revoked certificate can prevent legitimate users from reaching the site until the end of the duration[1]. The preload option can have permanent consequences if the site has to go back to HTTP[3]. Conversely, omitting includeSubDomains leaves cookie-related attacks open, because a subdomain can manipulate cookies[3].
- A header in the wrong place. A meta tag that repeats X-Frame-Options does not work: a real response header is needed, and the same rule applies to frame-ancestors[4]. A proxy that removes the header also causes the protection to be lost[4].
- Believing the problem is solved. The ALLOW-FROM value is obsolete and has no effect in modern browsers[4]. DoubleClickjacking, which goes through separate windows, is not stopped by these frame-display restrictions: OWASP asks for sensitive actions to be protected on the server side[4].
Real cases
2014: forbes.com, a legitimate site used to reach its visitors
The MITRE entry on "drive-by" compromise files under this technique the cases where an internet user is attacked while visiting a site during normal browsing, for example because a legitimate site has been compromised and malicious code injected into it[9]. It cites the group APT19, which carried out a "watering hole" attack on forbes.com in 2014 to compromise targets[9]. This type of attack often targets a site visited by a specific community, and the goal is to reach a specific user or group of users[9]. This case shows that the page visited is not necessarily the one that is malicious at the outset[9].
Sources
- OWASP, “HTTP Security Response Headers Cheat Sheet”. https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html (accessed 10 November 2026)
- OWASP, “Content Security Policy Cheat Sheet”. https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html (accessed 10 November 2026)
- OWASP, “HTTP Strict Transport Security Cheat Sheet”. https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Strict_Transport_Security_Cheat_Sheet.html (accessed 10 November 2026)
- OWASP, “Clickjacking Defense Cheat Sheet”. https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html (accessed 10 November 2026)
- OWASP, “OWASP Secure Headers Project”. https://owasp.org/projects/secure-headers-project (accessed 10 November 2026)
- OWASP, “Clickjacking”. https://community.owasp.org/attacks/Clickjacking (accessed 10 November 2026)
- Microsoft, “Enable Cross-Origin Requests (CORS) in ASP.NET Core”. https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-10.0 (accessed 10 November 2026)
- Microsoft, “What is Azure Web Application Firewall?”. https://learn.microsoft.com/en-us/azure/web-application-firewall/overview (accessed 10 November 2026)
- MITRE ATT&CK, “Drive-by Compromise”. https://attack.mitre.org/techniques/T1189/ (accessed 10 November 2026)
Cite this article
Brain, “HTTP security headers”, Cyberpedia, 2026. https:/
BibTeX
@misc{brain_cp230_en_2026,
author = {Brain},
title = {HTTP security headers},
year = {2026},
howpublished = {Cyberpedia},
url = {https://startbrain.io/cyberpedia/en/articles/http-security-headers-csp-hsts/},
note = {CC BY 4.0}
}