A picture of Jeff Brigman
Overcome
& Conquer

Security Headers Explained in Simple Terms

March 9, 2024

Imagine your website as your digital home. Just like your physical home has locks on the doors and windows, rules for guests, and guidelines for safety, your website needs similar protections to ensure it’s secure, private, and functioning as intended. Security headers are these digital safeguards. Let’s explore some key security headers to understand their roles in protecting your website.

Access-Control-Allow-Methods “GET,POST”
This is akin to specifying which doors can be used for entering or exiting your house—either the front door (GET) or the back door (POST). It limits how data is exchanged with your site, ensuring only the intended methods are used.

Access-Control-Allow-Headers “Content-Type, Authorization”
Imagine this as dictating what kind of identification is acceptable at your door—like a key card (Content-Type) or a password (Authorization). This ensures that only requests with the proper credentials can interact with your site.

Content-Security-Policy “upgrade-insecure-requests; frame-ancestors ‘self'”
Think of this as upgrading any old locks to high-security ones if they’re found to be vulnerable and ensuring only your own windows (frame-ancestors) can display your home’s view. This policy upgrades insecure requests to secure ones and prevents others from embedding your site in a way that could be malicious.

Cross-Origin-Embedder-Policy “unsafe-none; report-to=’default'”
This is like allowing items from anywhere into your home but keeping a record of where they came from. It manages how resources from external sources are treated, ensuring transparency and safety.

Cross-Origin-Opener-Policy “unsafe-none”
Consider this as deciding whether new guests can bring in items that connect to or interact with the items already in your home, without extra checks. It allows for the free flow of external resources but with less strict isolation.

Cross-Origin-Resource-Policy “cross-origin”
This is equivalent to setting rules for which neighbors can borrow your belongings. It controls how your website’s resources can be shared with or used by other sites.

Permissions-Policy
Imagine this as specifying which activities are allowed in your home, such as which rooms can be accessed and which appliances can be used. It fine-tunes the features and APIs your website can use and how they are permitted across different contexts. To learn more about all the different options (directives), check out this document from Mozilla.

Referrer-Policy “strict-origin-when-cross-origin”
This is like telling your friends they can mention they visited your house but not divulge the specifics of what went on inside when talking to strangers. It controls how much information your website shares about its visitors and where they came from.

Strict-Transport-Security “max-age=63072000”
Think of this as committing your home to use a high-security alarm system for a long time, ensuring that all points of entry are equally secure. This forces your site to use secure connections exclusively.

X-Content-Type-Options “nosniff”
This is like having a rule against guessing what’s inside a package without opening it properly. It prevents browsers from trying to guess and misinterpret the type of data being delivered, ensuring they only process data as explicitly stated.

X-Frame-Options “SAMEORIGIN”
Consider this as preventing your neighbors from putting up a window that looks directly into your home. It stops others from framing your content within their sites, protecting against clickjacking attacks.

X-Permitted-Cross-Domain-Policies “none”
This can be seen as not allowing your belongings to be used in someone else’s home. It restricts how your site’s data can be interacted with through certain cross-domain policies, offering an additional layer of control.

By understanding and implementing these security headers, you’re effectively setting the rules of engagement for your digital home. Just as you wouldn’t leave your front door unlocked, these headers ensure your website remains secure, private, and under your control. One thing to remember, is that it’s possible to make your site and digital home so secure that you end up restricting or blocking things your site actually needs to function. So be sure to test, test, test.

As the internet changes, so do security headers and how they are used. In some cases they may stop using one because a better version is available. A great example is X-XSS-Protection. It’s no longer used and has been replaced by Content-Security-Policy (CSP).

If you need to implement Security Headers into your website, here’s more info on how to do this: How to Easily Add Security Headers to your Site. If you’re not sure how to do it, no problem, just contact me and I’ll help.

Help support my work by buying me a cup of coffee