HSTS vs CSP in OutSystems: what each does and where to configure it
HSTS and CSP sit side by side in the environment security settings, which is why so many people mix them up. They solve different problems: one protects the channel, the other limits where content comes from. Here's what each does in OutSystems and where to configure it.
The situation
After a penetration test, the report recommends three things for the production environment:
- "Make sure the browser never accesses the site over HTTP."
- "Restrict where pages can load scripts and images from."
- "Prevent pages from being displayed inside frames on other sites."
Item 1 is solved with HSTS. Items 2 and 3, with CSP.
HSTS: always HTTPS
The HTTP Strict Transport Security (HSTS) header tells the browser it must never load the site over HTTP: every HTTP attempt automatically becomes HTTPS. This makes downgrade attacks and cookie theft on insecure networks harder.
OutSystems 11 has three related options:
| Option | Scope | What it does |
|---|---|---|
| Enable HTTP Strict Transport Security (HSTS) | whole environment only | all screens over HTTPS; HTTP requests redirected |
| Force HTTPS for screens in Web Applications | environment or app | all web screens over HTTPS |
| Force HTTPS for exposed integrations | environment or app | exposed SOAP and REST services over HTTPS only |
Reactive and Mobile apps always use HTTPS, so these options matter most for Traditional Web apps. Even so, HSTS is required in some Reactive scenarios, such as SAML login and cookies with the Secure flag.
Where to configure: in LifeTime, under Environments, pick the environment and click More Security Settings (for an app: Applications → app → Security Settings). Without LifeTime, in the environment's Service Center, under Administration → Security. All of them require a valid SSL certificate.
CSP: where the browser may load content from
Content Security Policy (CSP) declares which origins the browser may load content from, using directives:
| Directive | Controls |
|---|---|
default-src |
the default rule, used when no other applies (usually self) |
script-src |
where scripts may come from |
img-src |
where images may come from |
frame-ancestors |
which sites may show the page in a frame: the defense against clickjacking |
Where to configure: in LifeTime, under Infrastructure → Environment Security (environment) or Applications → app → Security Settings (app). Without LifeTime, in Service Center, under Administration → Security (environment) or Factory → app → Security tab (app).
Three practical rules:
- The app's policy overrides the environment's.
- After changing the CSP, republish the apps.
- Track blocked content in Service Center → Monitoring → Errors, with Source = CSPReport.
And two risks: an incomplete policy breaks videos, styles and scripts the app uses; an overly permissive policy, with *, cancels out most of the protection.
HSTS vs CSP side by side
| HSTS | CSP |
|---|---|
| forces the browser to use HTTPS | limits where the browser loads content from |
| protects the channel | reduces the impact of XSS and prevents clickjacking |
| whole environment only | per environment or per app (the app's wins) |
What about ODC?
In ODC, HSTS is on by default and CSP is configured per stage in the ODC Portal, as a list of allowed origins.
How it shows up in the exam
Secure Connections is worth 2 questions, and CSP also appears in the XSS ones. The traps:
- HSTS ≠ CSP.
- HSTS can only be enabled for the whole environment, not per app.
- The app's CSP overrides the environment's.
- Changed the CSP? Republish.
*in the CSP is almost the same as having no CSP.
See also secure cookies in OutSystems, which depend on forced HTTPS, and the full map in Security Specialist: what the exam is like and how to study.
Bloquest is independent and not affiliated with OutSystems.