A web application is expected to place restrictions on whether it is allowed to be rendered within frames, iframes, objects, embed or applet elements. Without the restrictions, users can be tricked into interacting with the application when they were not intending to.
1import express, { Express, Request, Response } from 'express'
2var app : Express = express()
3function improperRestrictionOfFramesNoncompliant() {
4 app.use((req: Request, res: Response) => {
5 // Noncompliant: it has broken `X-Frame-Options` header.
6 res.setHeader("X-Frame-Options", req.query)
7 })
8}
1import express, { Express, Request, Response } from 'express'
2var app : Express = express()
3function improperRestrictionOfFramesCompliant() {
4 app.use((req: Request, res: Response) => {
5 var host = req.query.opts
6 // Compliant: it has safe `X-Frame-Options` header.
7 res.setHeader("X-Frame-Options", "https://example.com")
8 })
9}