{"id":"6b09a4b7ff996234422a26ce","slug":"owasp-top-10-in-practice","title":"OWASP Top 10:2025 in practice – vulnerable and fixed code in Node.js, Express and React (with live XSS examples)","summary":"We walk through the current OWASP Top 10:2025 using the pierogi shop's online store – for every category a real bug in Node.js/Express or React and its fix. IDOR and SSRF (now in A01), misconfiguration, the supply chain, cryptography, SQL and NoSQL injection with a runnable demo, XSS in two interactive playgrounds, insecure design, authentication, integrity (SRI), security event logging and fail-closed exception handling.","servedLang":"en","availableLangs":["pl","en"],"topics":["web-security","api-security","react","express"],"techs":["node","typescript","javascript"],"tags":["owasp-top-10","owasp-2025","xss","sql-injection","nosql-injection","ssrf","idor","broken-access-control","supply-chain","dompurify","sri","react","express"],"level":"intermediate","kind":"tutorial","access":"public","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":19,"stats":{"views":1,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-27T15:41:43.532Z","updatedAt":"2026-11-27T17:32:39.382Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"rose","background":"hex","weaveResources":true,"toc":"right"},"seoDescription":"OWASP Top 10 2025 with code examples – Broken Access Control (IDOR, SSRF), Security Misconfiguration, Software Supply Chain Failures, Cryptographic Failures, Injection (SQL, NoSQL, XSS), Insecure Design, Authentication Failures, Software or Data Integrity Failures (SRI), Security Logging and Alertin","wordCount":3793,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Halina's pierogi shop no longer sells only over the counter, but also through an online store: click-and-collect orders, customer reviews, an admin panel that imports menus from suppliers. The first penetration test produced a 40-page report. Almost every finding mapped to one of the "},{"type":"text","text":"OWASP Top 10","marks":[{"type":"bold"}]},{"type":"text","text":" categories – the list of the most important web application risks. In this tutorial we go through its current edition, "},{"type":"text","text":"OWASP Top 10:2025","marks":[{"type":"bold"}]},{"type":"text","text":", and for each category show vulnerable code, the fix and how to check that it works."}]},{"type":"callout","attrs":{"variant":"info","title":"In a nutshell"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"The most common flaw is still missing access control.","marks":[{"type":"bold"}]},{"type":"text","text":" A01 is checking "},{"type":"text","text":"whether this user may see this object","marks":[{"type":"italic"}]},{"type":"text","text":" – in every query, on the server. In the 2025 edition it also covers SSRF."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"User input is data, not code.","marks":[{"type":"bold"}]},{"type":"text","text":" Parameters in SQL, shape validation before a MongoDB query, text instead of HTML in the browser (and when HTML is truly needed – DOMPurify)."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Two new categories are about maturity.","marks":[{"type":"bold"}]},{"type":"text","text":" A03 (software supply chain) and A10 (handling exceptional conditions) are about what you use and how your application fails – not only how it was written."}]}]}]}]},{"type":"callout","attrs":{"variant":"tip","title":"What you will build"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fixed versions of typical vulnerable parts of the store in Express (TypeScript): orders with an ownership check, a safe menu import from a URL (SSRF protection with a real test result), a runnable SQL injection demo on the SQLite built into Node.js 24, an endpoint resistant to NoSQL injection, a hardened Express setup, token generation, Subresource Integrity, refunds with a fail-closed check and security event logging. Plus two playgrounds you can edit in the browser: DOM XSS ("},{"type":"text","text":"innerHTML","marks":[{"type":"code"}]},{"type":"text","text":" vs "},{"type":"text","text":"textContent","marks":[{"type":"code"}]},{"type":"text","text":") and XSS in React ("},{"type":"text","text":"dangerouslySetInnerHTML","marks":[{"type":"code"}]},{"type":"text","text":" vs DOMPurify)."}]}]},{"type":"paragraph","content":[{"type":"text","text":"Prerequisites:","marks":[{"type":"bold"}]},{"type":"text","text":" JavaScript/TypeScript, Express basics ("},{"type":"text","text":"Express tutorial","marks":[{"type":"link","attrs":{"href":"/en/articles/express"}}]},{"type":"text","text":") and React ("},{"type":"text","text":"React tutorial","marks":[{"type":"link","attrs":{"href":"/en/articles/react"}}]},{"type":"text","text":"), SQL. The SQL injection demo needs Node.js 24 (the "},{"type":"text","text":"node:sqlite","marks":[{"type":"code"}]},{"type":"text","text":" module)."}]},{"type":"stats","attrs":{"items":[{"value":"10","label":"risk categories","hint":"the 2025 edition, the eighth ever"},{"value":"2","label":"new categories","hint":"A03 supply chain, A10 exceptional conditions"},{"value":"A01","label":"Broken Access Control","hint":"still number one, now including SSRF"},{"value":"2021 → 2025","label":"the first major update in 4 years","hint":"final version in early 2026"}]}},{"type":"timeline","attrs":{"items":[{"date":"2003","title":"The first list","text":"OWASP publishes its first Top 10 web application risks"},{"date":"2010–2017","title":"Further editions","text":"2010, 2013, 2017 – data from companies and the community, XXE and deserialization in 2017"},{"date":"2021","title":"Seventh edition","text":"Insecure Design, SSRF and Software and Data Integrity Failures for the first time"},{"date":"2025","title":"Eighth edition","text":"release candidate in November 2025, final version in early 2026 – new A03 and A10"}]}},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"2025"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Category"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"What changed since 2021"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A01"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Broken Access Control"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"still 1st; SSRF (formerly A10:2021) absorbed into this category"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A02"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Security Misconfiguration"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"up from 5th place"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A03"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Software Supply Chain Failures"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"new","marks":[{"type":"bold"}]},{"type":"text","text":", extends the former \"Vulnerable and Outdated Components\" to the whole chain: dependencies, builds, CI/CD"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A04"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Cryptographic Failures"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"down from 2nd"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A05"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Injection"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"down from 3rd; still includes XSS"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A06"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Insecure Design"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"down from 4th"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A07"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Authentication Failures"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a new, shorter name"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A08"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Software or Data Integrity Failures"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"no major changes"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A09"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Security Logging and Alerting Failures"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"emphasis on alerting, not just logging"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A10"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Mishandling of Exceptional Conditions"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"new","marks":[{"type":"bold"}]},{"type":"text","text":": exception-handling bugs, fail-open, leaks in error messages"}]}]}]}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"flowchart LR\n  B([Customer browser]) -->|A05 XSS, A07 login| API[Express API]\n  ADM([Admin panel]) -->|A01 menu import from URL → SSRF| API\n  API -->|A01 IDOR, A05 SQL/NoSQL| DB[(PostgreSQL / MongoDB)]\n  API -->|A01 SSRF| META[(169.254.169.254<br/>cloud metadata)]\n  API -->|A03 npm dependencies| NPM[(npm, CDN)]\n  API -->|A09 security events| LOG[(Logs and alarms)]\n  B -->|A08 CDN scripts – SRI| NPM","caption":"The pierogi store's attack surface and where the OWASP categories show up"}},{"type":"heading","attrs":{"level":2,"id":"a01-broken-access-control-idor-and-ssrf"},"content":[{"type":"text","text":"A01 Broken Access Control: IDOR and SSRF"}]},{"type":"paragraph","content":[{"type":"text","text":"A customer signed in to their account opens "},{"type":"text","text":"/api/orders/1041","marks":[{"type":"code"}]},{"type":"text","text":". They change the number to "},{"type":"text","text":"1042","marks":[{"type":"code"}]},{"type":"text","text":" – and see someone else's order with an address and phone number. That's IDOR ("},{"type":"text","text":"insecure direct object reference","marks":[{"type":"italic"}]},{"type":"text","text":"), known as BOLA in the API world. Login worked perfectly; what was missing was the question \"does this order belong to this user?\"."}]},{"type":"codeGroup","attrs":{"title":"IDOR: a vulnerable and a fixed orders endpoint"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/orders.vulnerable.ts"},"content":[{"type":"text","text":"import { Router } from 'express';\nimport pg from 'pg';\nimport { requireAuth } from './types.js';\n\nconst db = new pg.Pool();\nexport const orders = Router();\n\n// ❌ A01 Broken Access Control (IDOR/BOLA): any logged-in customer reads ANY order\n//    by changing the number in the URL: /api/orders/1041 → /api/orders/1042\norders.get('/api/orders/:id', requireAuth, async (req, res) => {\n  const { rows } = await db.query('SELECT * FROM orders WHERE id = $1', [req.params.id]);\n  res.json(rows[0]); // also leaks every column: address, phone, internal notes\n});"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/orders.fixed.ts"},"content":[{"type":"text","text":"import { Router } from 'express';\nimport pg from 'pg';\nimport { requireAuth } from './types.js';\n\nconst db = new pg.Pool();\nexport const orders = Router();\n\n// ✅ The ownership check is part of the query, and only the needed columns leave the server.\norders.get('/api/orders/:id', requireAuth, async (req, res) => {\n  const { rows } = await db.query(\n    'SELECT id, status, total, items, created_at FROM orders WHERE id = $1 AND customer_id = $2',\n    [req.params.id, req.user.id],\n  );\n  if (!rows[0]) { res.sendStatus(404); return; } // 404, not 403 – don't confirm the order exists\n  res.json(rows[0]);\n});"}]}]},{"type":"paragraph","content":[{"type":"text","text":"The ownership check is part of the query ("},{"type":"text","text":"AND customer_id = $2","marks":[{"type":"code"}]},{"type":"text","text":"), not a separate "},{"type":"text","text":"if","marks":[{"type":"code"}]},{"type":"text","text":" added \"somewhere later\". Plus only the needed columns and a 404 instead of a 403, so you don't confirm that other people's orders exist. Random identifiers (UUIDs) make guessing harder but "},{"type":"text","text":"don't replace authorization","marks":[{"type":"bold"}]},{"type":"text","text":" – identifiers leak in links, logs and emails."}]},{"type":"paragraph","content":[{"type":"text","text":"SSRF","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"server-side request forgery","marks":[{"type":"italic"}]},{"type":"text","text":") is part of A01 in the 2025 edition: the server makes a request to an address supplied by the user and thereby reaches places the user cannot – internal network services or the cloud metadata service ("},{"type":"text","text":"169.254.169.254","marks":[{"type":"code"}]},{"type":"text","text":"), which on EC2 with IMDSv1 hands out the role's temporary credentials."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"sequenceDiagram\n  participant X as Attacker (store admin account)\n  participant A as Store API (EC2)\n  participant M as Metadata service 169.254.169.254\n  X->>A: POST /api/admin/menu/import {url: \"http://169.254.169.254/…\"}\n  A->>M: GET (from inside the cloud – access works)\n  M-->>A: temporary role credentials (IMDSv1)\n  A-->>X: \"menu preview\" = credentials\n  Note over A,M: fix: host allowlist, public IPs only, IMDSv2, no echoing the response","caption":"SSRF: the server as a proxy into places the attacker cannot reach"}},{"type":"codeGroup","attrs":{"title":"SSRF: importing a menu from a supplier's URL"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/menu-import.vulnerable.ts"},"content":[{"type":"text","text":"import { Router } from 'express';\nimport { requireAdmin } from './types.js';\n\nexport const menuImport = Router();\n\n// ❌ A01 (SSRF): \"import the menu from your supplier's URL\" – the server fetches whatever it's told:\n//    http://169.254.169.254/latest/meta-data/..., http://localhost:6379, http://10.20.3.7/admin\nmenuImport.post('/api/admin/menu/import', requireAdmin, async (req, res) => {\n  const response = await fetch(req.body.url);\n  res.json({ preview: (await response.text()).slice(0, 500) }); // …and even shows the answer\n});"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/menu-import.fixed.ts"},"content":[{"type":"text","text":"import { Router } from 'express';\nimport { z } from 'zod';\nimport { requireAdmin } from './types.js';\nimport { assertSafeUrl } from './safe-url.js';\n\nexport const menuImport = Router();\nconst Menu = z.array(z.object({ name: z.string().max(120), price: z.number().positive() })).max(500);\ndeclare function saveMenu(menu: z.infer<typeof Menu>): Promise<void>;\n\n// ✅ allowlist + https + public IPs only + no redirects + timeout + size limit + schema validation\nmenuImport.post('/api/admin/menu/import', requireAdmin, async (req, res) => {\n  const url = await assertSafeUrl(String(req.body.url)).catch(() => null);\n  if (!url) { res.status(400).json({ error: 'url_not_allowed' }); return; }\n\n  const response = await fetch(url, { redirect: 'error', signal: AbortSignal.timeout(5_000) });\n  if (!response.ok) { res.status(502).json({ error: 'supplier_unavailable' }); return; }\n  if (Number(response.headers.get('content-length') ?? 0) > 1_000_000) { res.sendStatus(413); return; }\n\n  const menu = Menu.safeParse(await response.json());\n  if (!menu.success) { res.status(422).json({ error: 'invalid_menu' }); return; }\n  await saveMenu(menu.data); // never echo the raw upstream body back to the client\n  res.sendStatus(204);\n});"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/safe-url.ts"},"content":[{"type":"text","text":"import { lookup } from 'node:dns/promises';\nimport { BlockList, isIP } from 'node:net';\n\n// Private, loopback, link-local (incl. 169.254.169.254 – the EC2 metadata service) and other internal ranges.\nconst internal = new BlockList();\nfor (const [net, prefix] of [['0.0.0.0', 8], ['10.0.0.0', 8], ['100.64.0.0', 10], ['127.0.0.0', 8],\n  ['169.254.0.0', 16], ['172.16.0.0', 12], ['192.168.0.0', 16]] as const) internal.addSubnet(net, prefix, 'ipv4');\nfor (const [net, prefix] of [['::', 128], ['::1', 128], ['fc00::', 7], ['fe80::', 10]] as const) internal.addSubnet(net, prefix, 'ipv6');\n\nconst isInternal = (ip: string) => {\n  const mapped = ip.match(/^::ffff:(\\d+\\.\\d+\\.\\d+\\.\\d+)$/i)?.[1]; // IPv4-mapped IPv6\n  return mapped ? internal.check(mapped, 'ipv4') : internal.check(ip, isIP(ip) === 6 ? 'ipv6' : 'ipv4');\n};\n\nconst ALLOWED_HOSTS = new Set(['menu.partner-courier.example', 'cdn.supplier.example']);\n\n/** Throws unless the URL is https, on the allowlist and resolves only to public addresses. */\nexport async function assertSafeUrl(raw: string): Promise<URL> {\n  const url = new URL(raw); // throws on garbage\n  if (url.protocol !== 'https:') throw new Error('only https is allowed');\n  if (url.username || url.password) throw new Error('credentials in URL are not allowed');\n  if (!ALLOWED_HOSTS.has(url.hostname)) throw new Error(`host not allowed: ${url.hostname}`);\n  const addresses = await lookup(url.hostname, { all: true });\n  if (addresses.some((a) => isInternal(a.address))) throw new Error('resolves to an internal address');\n  return url;\n}\n\nexport { isInternal };"}]}]},{"type":"output","attrs":{"title":"Testing the URL guard – output of node dist/ssrf-check.js","language":"text","content":"169.254.169.254          BLOCKED\n10.20.1.5                BLOCKED\n::ffff:169.254.169.254   BLOCKED\nfd00:ec2::254            BLOCKED\n8.8.8.8                  public\n2a00:1450:4001::200e     public\nREJECT  http://169.254.169.254/latest/meta-data/ → only https is allowed\nREJECT  https://localhost:8080/admin → host not allowed: localhost\nREJECT  file:///etc/passwd → only https is allowed\nREJECT  https://menu.partner-courier.example@169.254.169.254/ → credentials in URL are not allowed"}},{"type":"paragraph","content":[{"type":"text","text":"A host allowlist is the strongest control; checking IP addresses after DNS resolution is the second layer (it catches, for example, IPv4 written as IPv6 and the IPv6 metadata address "},{"type":"text","text":"fd00:ec2::254","marks":[{"type":"code"}]},{"type":"text","text":"). Remember the limitation code can't solve: between the check and the connection, DNS may answer differently ("},{"type":"text","text":"DNS rebinding","marks":[{"type":"italic"}]},{"type":"text","text":"). That's why we add network controls – IMDSv2 required on instances, outbound traffic through a proxy with a domain list, security groups without internal network access for services that fetch user-supplied URLs."}]},{"type":"heading","attrs":{"level":2,"id":"a02-a04-a08-configuration-cryptography-and-integrity"},"content":[{"type":"text","text":"A02, A04, A08: configuration, cryptography and integrity"}]},{"type":"paragraph","content":[{"type":"text","text":"Three categories that rarely need much code but are easy to forget:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A02 Security Misconfiguration","marks":[{"type":"bold"}]},{"type":"text","text":" – framework defaults, detailed errors with stack traces for clients, open admin panels, "},{"type":"text","text":"Access-Control-Allow-Origin: *","marks":[{"type":"code"}]},{"type":"text","text":" with cookies, public buckets. In Express we start with "},{"type":"text","text":"helmet()","marks":[{"type":"code"}]},{"type":"text","text":", a body size limit and a single error handler. Headers are covered in detail in "},{"type":"text","text":"Security headers and CSP","marks":[{"type":"link","attrs":{"href":"/en/articles/security-headers-and-csp"}}]},{"type":"text","text":", and buckets in "},{"type":"text","text":"S3 bucket security","marks":[{"type":"link","attrs":{"href":"/en/articles/aws-s3-bucket-security"}}]},{"type":"text","text":"."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A04 Cryptographic Failures","marks":[{"type":"bold"}]},{"type":"text","text":" – "},{"type":"text","text":"Math.random()","marks":[{"type":"code"}]},{"type":"text","text":" in password reset tokens, MD5 and SHA-256 for passwords, tokens stored in plain text, no TLS. Generate tokens with "},{"type":"text","text":"crypto.randomBytes","marks":[{"type":"code"}]},{"type":"text","text":", store only their hash, hash passwords with argon2id ("},{"type":"text","text":"authentication tutorial","marks":[{"type":"link","attrs":{"href":"/en/articles/authentication"}}]},{"type":"text","text":")."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A08 Software or Data Integrity Failures","marks":[{"type":"bold"}]},{"type":"text","text":" – code or data whose integrity nobody checks: a script from a CDN, an update downloaded without a signature, an unsigned cookie holding the user's role, deserializing objects from an untrusted source. For CDN scripts – "},{"type":"text","text":"Subresource Integrity","marks":[{"type":"bold"}]},{"type":"text","text":" (the "},{"type":"text","text":"integrity","marks":[{"type":"code"}]},{"type":"text","text":" attribute; I computed the hash below from the npm file and checked it against jsDelivr's response)."}]}]}]},{"type":"codeGroup","attrs":{"title":"Hardened Express, tokens and Subresource Integrity"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/hardening.ts"},"content":[{"type":"text","text":"import express, { type ErrorRequestHandler } from 'express';\nimport helmet from 'helmet';\nimport { randomUUID } from 'node:crypto';\nimport { pino } from 'pino';\n\nconst log = pino();\nconst app = express();\n\n// A02 Security Misconfiguration: safe defaults instead of framework defaults.\napp.use(helmet()); // security headers, removes X-Powered-By\napp.use(express.json({ limit: '100kb' })); // no 50 MB JSON bodies\napp.use((req, res, next) => { res.locals.requestId = randomUUID(); next(); });\n\n// …routes…\n\n// A10 Mishandling of Exceptional Conditions: one place for errors, no stack traces for clients.\nconst onError: ErrorRequestHandler = (err, req, res, _next) => {\n  log.error({ err, requestId: res.locals.requestId, path: req.path }, 'unhandled error');\n  res.status(500).json({ error: 'internal_error', requestId: res.locals.requestId });\n};\napp.use(onError);\nprocess.on('unhandledRejection', (reason) => { log.fatal({ reason }, 'unhandled rejection'); process.exit(1); });\n\nexport { app };"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/tokens.ts"},"content":[{"type":"text","text":"import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';\n\n// ❌ A04 Cryptographic Failures: Math.random() is predictable – never for tokens, codes or reset links\nexport const weakToken = () => Math.random().toString(36).slice(2);\n\n// ✅ a CSPRNG, 256 bits, URL-safe; store only the hash, compare in constant time\nexport const newResetToken = () => randomBytes(32).toString('base64url');\nexport const hashToken = (token: string) => createHash('sha256').update(token).digest();\nexport const sameHash = (a: Buffer, b: Buffer) => a.length === b.length && timingSafeEqual(a, b);\n// Passwords: never SHA-256/MD5 – use argon2id (see the authentication tutorial)."}]},{"type":"codeBlock","attrs":{"language":"html","filename":"public/index.html"},"content":[{"type":"text","text":"<!-- A08 Software or Data Integrity Failures: a script from a CDN must be exactly the file you reviewed.\n     If the CDN (or someone who hijacked it) serves different bytes, the browser refuses to run them. -->\n<script\n  src=\"https://cdn.jsdelivr.net/npm/dompurify@3.5.0/dist/purify.min.js\"\n  integrity=\"sha384-DOUwTXbuiiQxlONuue5N42674XXDfjIJ/LTPtJMZ2ZV1Ir4NRQ3OnM/yM505YQAc\"\n  crossorigin=\"anonymous\"\n></script>\n<!-- Generate the hash: curl -s <url> | openssl dgst -sha384 -binary | openssl base64 -A -->"}]}]},{"type":"heading","attrs":{"level":2,"id":"a03-software-supply-chain-failures"},"content":[{"type":"text","text":"A03 Software Supply Chain Failures"}]},{"type":"paragraph","content":[{"type":"text","text":"The new category describes a risk that stopped being theoretical in recent years. In September 2025 a hijacked maintainer account of popular npm packages (including "},{"type":"text","text":"chalk","marks":[{"type":"code"}]},{"type":"text","text":" and "},{"type":"text","text":"debug","marks":[{"type":"code"}]},{"type":"text","text":") was used to publish versions with malicious code that ran in the browsers of users of applications that installed them. A few days later the "},{"type":"text","text":"Shai-Hulud","marks":[{"type":"bold"}]},{"type":"text","text":" worm started spreading on its own: it stole npm and GitHub tokens from developer machines and pipelines, then published infected versions of further packages; a second, broader wave followed in November 2025. In March 2025 and March 2026 attackers moved the tags of popular GitHub Actions ("},{"type":"text","text":"tj-actions/changed-files","marks":[{"type":"code"}]},{"type":"text","text":", the Trivy actions) to malicious commits."}]},{"type":"paragraph","content":[{"type":"text","text":"The minimum defence: a lockfile and "},{"type":"text","text":"npm ci","marks":[{"type":"code"}]},{"type":"text","text":" in CI, reviewed and delayed updates (Renovate/Dependabot with a cooldown), dependency scanning (npm audit, OSV-Scanner), an SBOM, GitHub Actions pinned to a SHA, no long-lived publishing tokens (trusted publishing via OIDC). I show the whole setup in the "},{"type":"text","text":"DevSecOps pipeline tutorial","marks":[{"type":"link","attrs":{"href":"/en/articles/devsecops-pipeline"}}]},{"type":"text","text":"."}]},{"type":"heading","attrs":{"level":2,"id":"a05-injection-sql-nosql-and-xss"},"content":[{"type":"text","text":"A05 Injection: SQL, NoSQL and XSS"}]},{"type":"paragraph","content":[{"type":"text","text":"Injection always works the same way: user data reaches an interpreter (SQL, a MongoDB query, HTML, a shell) as part of a command. You can run the demo below without a database – Node.js 24 has SQLite built in."}]},{"type":"codeGroup","attrs":{"title":"SQL injection (runnable demo) and NoSQL injection"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/sqli-demo.ts"},"content":[{"type":"text","text":"// Runnable demo: node sqli-demo.ts (Node 24) – an in-memory SQLite, no database server needed.\nimport express from 'express';\nimport { DatabaseSync } from 'node:sqlite';\n\nconst db = new DatabaseSync(':memory:');\ndb.exec(`CREATE TABLE orders (id INTEGER PRIMARY KEY, customer TEXT, total REAL);\n  INSERT INTO orders (customer, total) VALUES ('anna', 64.5), ('bartek', 38.0), ('celina', 121.0);`);\nconst app = express();\n\n// ❌ A05 Injection: user input glued into SQL\napp.get('/v1/orders', (req, res) => {\n  const sql = `SELECT id, customer, total FROM orders WHERE customer = '${req.query.customer}'`;\n  res.json(db.prepare(sql).all());\n});\n\n// ✅ a parameterized query: the input is data, never code (pg: 'WHERE customer = $1', [customer])\napp.get('/v2/orders', (req, res) => {\n  res.json(db.prepare('SELECT id, customer, total FROM orders WHERE customer = ?').all(String(req.query.customer)));\n});\n\napp.listen(3005, () => console.log('http://localhost:3005'));"}]},{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/pickup.nosql.ts"},"content":[{"type":"text","text":"import { Router } from 'express';\nimport mongoose from 'mongoose';\nimport { z } from 'zod';\n\nconst Order = mongoose.model('Order', new mongoose.Schema({ pickupCode: String, status: String }));\nexport const pickup = Router();\n\n// ❌ A05 NoSQL injection: body {\"code\": {\"$ne\": \"\"}} turns the filter into \"any order with a code\"\npickup.post('/v1/pickup', async (req, res) => {\n  const order = await Order.findOne({ pickupCode: req.body.code });\n  res.json(order ? { ok: true, orderId: order.id } : { ok: false });\n});\n\n// ✅ validate the shape and type first; sanitizeFilter as a safety net for the whole app\nmongoose.set('sanitizeFilter', true); // wraps $-operators coming from user objects in $eq\nconst PickupBody = z.object({ code: z.string().regex(/^[A-Z0-9]{8}$/) }).strict();\n\npickup.post('/v2/pickup', async (req, res) => {\n  const body = PickupBody.safeParse(req.body);\n  if (!body.success) { res.sendStatus(400); return; }\n  const order = await Order.findOne({ pickupCode: body.data.code });\n  res.json(order ? { ok: true, orderId: order.id } : { ok: false });\n});"}]}]},{"type":"output","attrs":{"title":"curl output for both versions of the endpoint (run locally)","language":"bash","content":"$ curl -s \"localhost:3005/v1/orders?customer=anna\"\n[{\"id\":1,\"customer\":\"anna\",\"total\":64.5}]\n$ curl -s \"localhost:3005/v1/orders?customer=x'%20OR%20'1'='1\"\n[{\"id\":1,\"customer\":\"anna\",\"total\":64.5},{\"id\":2,\"customer\":\"bartek\",\"total\":38},{\"id\":3,\"customer\":\"celina\",\"total\":121}]\n$ curl -s \"localhost:3005/v2/orders?customer=x'%20OR%20'1'='1\"\n[]"}},{"type":"paragraph","content":[{"type":"text","text":"The classic "},{"type":"text","text":"' OR '1'='1","marks":[{"type":"code"}]},{"type":"text","text":" turns the condition into one that is always true and returns every customer's orders. In the parameterized version the same text is just a customer name that doesn't exist in the database. In MongoDB the equivalent is an object with an operator ("},{"type":"text","text":"{\"$ne\": \"\"}","marks":[{"type":"code"}]},{"type":"text","text":") where you expect a string – so we validate the shape of the data first (zod), and Mongoose's "},{"type":"text","text":"sanitizeFilter","marks":[{"type":"code"}]},{"type":"text","text":" is the safety net."}]},{"type":"heading","attrs":{"level":3,"id":"xss-in-the-browser-try-it-yourself"},"content":[{"type":"text","text":"XSS in the browser – try it yourself"}]},{"type":"paragraph","content":[{"type":"text","text":"XSS","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"cross-site scripting","marks":[{"type":"italic"}]},{"type":"text","text":") is injection into HTML: text from one user becomes code in another user's browser. The playgrounds below use a classic, harmless payload – an image that fails to load, with an "},{"type":"text","text":"onerror","marks":[{"type":"code"}]},{"type":"text","text":" attribute. Instead of stealing cookies, it only changes a section's colour or shows an alarm."}]},{"type":"playground","attrs":{"template":"vanilla","files":{"/index.html":{"code":"<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\" />\n    <title>DOM XSS</title>\n  </head>\n  <body>\n    <main>\n      <label for=\"q\">Search the menu</label>\n      <input id=\"q\" autocomplete=\"off\" />\n      <section id=\"unsafe\"><h2>innerHTML ❌</h2><p class=\"out\"></p></section>\n      <section id=\"safe\"><h2>textContent ✅</h2><p class=\"out\"></p></section>\n    </main>\n    <script src=\"index.js\"></script>\n  </body>\n</html>"},"/index.js":{"code":"import \"./styles.css\";\n\n// A harmless classic: a broken <img> whose onerror marks the section red.\nconst PAYLOAD = `<img src=\"x\" onerror=\"this.closest('section').classList.add('pwned')\">ruskie`;\n\nconst input = document.getElementById(\"q\");\nconst unsafeOut = document.querySelector(\"#unsafe .out\");\nconst safeOut = document.querySelector(\"#safe .out\");\n\nfunction render() {\n  document.querySelectorAll(\"section\").forEach((s) => s.classList.remove(\"pwned\"));\n\n  // ❌ the input becomes HTML – tags and event handlers run inside our page\n  unsafeOut.innerHTML = `Results for: <b>${input.value}</b>`;\n\n  // ✅ the input stays text – build elements, set textContent\n  const b = document.createElement(\"b\");\n  b.textContent = input.value;\n  safeOut.replaceChildren(\"Results for: \", b);\n}\n\ninput.value = PAYLOAD;\ninput.addEventListener(\"input\", render);\nrender();","active":true},"/styles.css":{"code":"body { font-family: system-ui, sans-serif; margin: 0; padding: 16px; color: #1f2328; }\nmain { max-width: 640px; display: grid; gap: 10px; }\ninput { font: 13px ui-monospace, monospace; padding: 8px; }\nsection { border: 1px solid #d0d7de; border-radius: 8px; padding: 4px 12px; }\nsection h2 { font-size: 14px; margin: 8px 0 4px; }\n.out { word-break: break-all; }\n.pwned { background: #ffe3e3; border-color: #ff8787; }\n.pwned h2::after { content: \" – code from the search box just ran!\"; color: #a51111; }"}},"layout":"preview","height":430,"title":"DOM XSS: innerHTML vs textContent","caption":"Type your own text or change the payload – the code in the tabs is editable.","editable":true}},{"type":"paragraph","content":[{"type":"text","text":"In the first example "},{"type":"text","text":"innerHTML","marks":[{"type":"code"}]},{"type":"text","text":" interprets the typed text as HTML, so the browser creates an "},{"type":"text","text":"<img>","marks":[{"type":"code"}]},{"type":"text","text":" element and runs its "},{"type":"text","text":"onerror","marks":[{"type":"code"}]},{"type":"text","text":". "},{"type":"text","text":"textContent","marks":[{"type":"code"}]},{"type":"text","text":" (and building elements with "},{"type":"text","text":"createElement","marks":[{"type":"code"}]},{"type":"text","text":") inserts the "},{"type":"text","text":"<","marks":[{"type":"code"}]},{"type":"text","text":" and "},{"type":"text","text":">","marks":[{"type":"code"}]},{"type":"text","text":" characters as text."}]},{"type":"playground","attrs":{"template":"react","files":{"/App.js":{"code":"import { useEffect, useState } from \"react\";\nimport DOMPurify from \"dompurify\";\n\n// A harmless classic: an <img> that fails to load runs its onerror handler.\nconst SAMPLE = \"Best <b>pierogi</b> in town! <img src=\\\"x\\\" onerror=\\\"document.getElementById('alarm').hidden = false\\\">\";\n\nconst MODES = { unsafe: \"dangerouslySetInnerHTML ❌\", purified: \"DOMPurify ✅\", text: \"plain text ✅\" };\n\nexport default function App() {\n  const [review, setReview] = useState(SAMPLE);\n  const [mode, setMode] = useState(\"unsafe\");\n\n  // Hide the alarm on every change – it reappears only if the payload runs again.\n  useEffect(() => {\n    document.getElementById(\"alarm\").hidden = true;\n  }, [review, mode]);\n\n  const html =\n    mode === \"purified\"\n      ? DOMPurify.sanitize(review, { ALLOWED_TAGS: [\"b\", \"i\", \"em\", \"strong\", \"br\"], ALLOWED_ATTR: [] })\n      : review;\n\n  return (\n    <main>\n      <p id=\"alarm\" className=\"alarm\" hidden>⚠ Code from a customer review just ran in the browser!</p>\n      <label htmlFor=\"review\">Customer review (with HTML)</label>\n      <textarea id=\"review\" rows={3} value={review} onChange={(e) => setReview(e.target.value)} />\n      <div className=\"modes\">\n        {Object.entries(MODES).map(([key, label]) => (\n          <label key={key}>\n            <input type=\"radio\" name=\"mode\" checked={mode === key} onChange={() => setMode(key)} /> {label}\n          </label>\n        ))}\n      </div>\n      <h3>What other customers will see</h3>\n      {mode === \"text\" ? (\n        <p className=\"review\">{review}</p>\n      ) : (\n        <p className=\"review\" dangerouslySetInnerHTML={{ __html: html }} />\n      )}\n      <h3>HTML that reaches the DOM</h3>\n      <pre>{mode === \"text\" ? \"React inserts text – < and > are escaped\" : html}</pre>\n    </main>\n  );\n}","active":true},"/styles.css":{"code":"body { font-family: system-ui, sans-serif; margin: 0; padding: 16px; color: #1f2328; }\nmain { max-width: 640px; display: grid; gap: 10px; }\ntextarea { width: 100%; font: 13px ui-monospace, monospace; padding: 8px; box-sizing: border-box; }\n.modes { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; }\n.review { border: 1px solid #d0d7de; border-radius: 8px; padding: 10px 12px; min-height: 24px; }\npre { background: #f6f8fa; padding: 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; font-size: 12px; }\n.alarm { background: #ffe3e3; color: #a51111; border: 1px solid #ffa8a8; border-radius: 8px; padding: 8px 12px; margin: 0; font-weight: 600; }\nh3 { margin: 8px 0 0; font-size: 14px; }"}},"dependencies":{"dompurify":"^3.5.0"},"layout":"preview","height":560,"title":"XSS in customer reviews: dangerouslySetInnerHTML vs DOMPurify","caption":"Switch modes and watch the red alarm. The payload only changes the page inside the preview.","editable":true}},{"type":"paragraph","content":[{"type":"text","text":"React escapes everything you put in JSX by default – \"plain text\" mode is safe with no extra work. The risk appears when you bypass that mechanism: "},{"type":"text","text":"dangerouslySetInnerHTML","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"ref.current.innerHTML","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"javascript:","marks":[{"type":"code"}]},{"type":"text","text":" URLs in "},{"type":"text","text":"href","marks":[{"type":"code"}]},{"type":"text","text":" (React 19 blocks them and replaces them with a URL that throws an error; older versions only warned), or HTML from a WYSIWYG editor. If you really need HTML, run it through "},{"type":"text","text":"DOMPurify","marks":[{"type":"bold"}]},{"type":"text","text":" with a narrow tag allowlist – ideally on the server when saving and again in the browser when displaying. The second line of defence is a "},{"type":"text","text":"Content Security Policy","marks":[{"type":"bold"}]},{"type":"text","text":", which won't let an injected script run even if it reaches the page."}]},{"type":"heading","attrs":{"level":2,"id":"a06-insecure-design-a-flaw-in-the-design-not-the-code"},"content":[{"type":"text","text":"A06 Insecure Design: a flaw in the design, not the code"}]},{"type":"paragraph","content":[{"type":"text","text":"The pierogi shop's pickup codes had 4 digits. The code was flawless: validation, parameters, cashier authorization. The problem is that 10,000 combinations can be tried by a script in a few minutes, and an \"invalid code\" response limits nothing. No library fixes that – the design has to change: 8-character codes of letters and digits (almost 3 trillion combinations), an attempt limit per order and per IP address, a lockout after 5 failures, a notification to the customer."}]},{"type":"paragraph","content":[{"type":"text","text":"Problems like this are caught by "},{"type":"text","text":"threat modeling","marks":[{"type":"bold"}]},{"type":"text","text":" at design time (\"what can go wrong in this flow?\") and abuse cases written next to user stories. More on building that into the process in the "},{"type":"text","text":"DevSecOps pipeline tutorial","marks":[{"type":"link","attrs":{"href":"/en/articles/devsecops-pipeline"}}]},{"type":"text","text":"."}]},{"type":"heading","attrs":{"level":2,"id":"a07-authentication-failures"},"content":[{"type":"text","text":"A07 Authentication Failures"}]},{"type":"paragraph","content":[{"type":"text","text":"No limits on login attempts ("},{"type":"text","text":"credential stuffing","marks":[{"type":"italic"}]},{"type":"text","text":" from leaked databases), weak password resets, sessions that never expire, no MFA for the admin panel, session identifiers in URLs. This topic has its own, extensive tutorial: "},{"type":"text","text":"Login and registration","marks":[{"type":"link","attrs":{"href":"/en/articles/authentication"}}]},{"type":"text","text":" (argon2id, refresh token rotation, cookies, OAuth/OIDC, attempt limits). Rate limiting for the whole API is covered in "},{"type":"text","text":"API security","marks":[{"type":"link","attrs":{"href":"/en/articles/api-security"}}]},{"type":"text","text":"."}]},{"type":"heading","attrs":{"level":2,"id":"a09-and-a10-logging-alerting-and-exceptional-conditions"},"content":[{"type":"text","text":"A09 and A10: logging, alerting and exceptional conditions"}]},{"type":"paragraph","content":[{"type":"text","text":"The new category "},{"type":"text","text":"A10 Mishandling of Exceptional Conditions","marks":[{"type":"bold"}]},{"type":"text","text":" collects bugs that appear when something goes wrong: an exception swallowed in a "},{"type":"text","text":"catch","marks":[{"type":"code"}]},{"type":"text","text":" block that returns "},{"type":"text","text":"true","marks":[{"type":"code"}]},{"type":"text","text":", an unhandled promise rejection that brings the process down, database details in an error message for the client, a transaction aborted halfway. "},{"type":"text","text":"A09","marks":[{"type":"bold"}]},{"type":"text","text":" reminds us that without security events in logs and alerts on their growth, an attack goes on for weeks before anyone notices."}]},{"type":"codeGroup","attrs":{"title":"Refunds: fail-open vs fail-closed with event logging"},"content":[{"type":"codeBlock","attrs":{"language":"typescript","filename":"src/refunds.ts"},"content":[{"type":"text","text":"import { Router } from 'express';\nimport { pino } from 'pino';\nimport { requireAuth } from './types.js';\n\nconst log = pino();\ndeclare const policy: { check(userId: string, action: string, resourceId: string): Promise<boolean> };\nexport const refunds = Router();\n\n// ❌ A10: fail-open – when the policy service times out, EVERYONE may refund\nexport async function canRefundFailOpen(userId: string, orderId: string) {\n  try { return await policy.check(userId, 'order:refund', orderId); } catch { return true; }\n}\n\n// ✅ fail closed + A09: security events are logged (without secrets) so alarms can fire on spikes\nasync function canRefund(userId: string, orderId: string) {\n  try {\n    return await policy.check(userId, 'order:refund', orderId);\n  } catch (err) {\n    log.error({ err, event: 'authz.error', userId, orderId }, 'policy check failed – denying');\n    return false;\n  }\n}\n\nrefunds.post('/api/orders/:id/refund', requireAuth, async (req, res) => {\n  if (!(await canRefund(req.user.id, req.params.id))) {\n    log.warn({ event: 'authz.denied', userId: req.user.id, action: 'order:refund', orderId: req.params.id }, 'access denied');\n    res.sendStatus(403);\n    return;\n  }\n  // …refund…\n  res.sendStatus(202);\n});"}]}]},{"type":"paragraph","content":[{"type":"text","text":"The rule: when a security check errors, "},{"type":"text","text":"deny","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"fail closed","marks":[{"type":"italic"}]},{"type":"text","text":"). A customer who can't request a refund for a minute is a smaller problem than a minute in which anyone can refund any order. "},{"type":"text","text":"authz.denied","marks":[{"type":"code"}]},{"type":"text","text":" and "},{"type":"text","text":"authz.error","marks":[{"type":"code"}]},{"type":"text","text":" events (no passwords, tokens or personal data) go to the logs, and an alarm on a sudden spike goes to on-call ("},{"type":"text","text":"observability tutorial","marks":[{"type":"link","attrs":{"href":"/en/articles/aws-observability-and-cost"}}]},{"type":"text","text":")."}]},{"type":"heading","attrs":{"level":2,"id":"cheat-sheet-one-control-per-category"},"content":[{"type":"text","text":"Cheat sheet: one control per category"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Category"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"The key control in the store"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"How to check"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A01"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"owner in every query, host allowlist for fetches"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"tests with two accounts, a "},{"type":"text","text":"169.254.169.254","marks":[{"type":"code"}]},{"type":"text","text":" attempt"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A02"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"helmet, limits, one error handler, no default passwords"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"header scan, IaC configuration review"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A03"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"lockfile, "},{"type":"text","text":"npm ci","marks":[{"type":"code"}]},{"type":"text","text":", dependency scanning, actions pinned to SHA"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"npm audit / OSV-Scanner in CI"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A04"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a CSPRNG for tokens, argon2id for passwords, TLS"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"code review, TLS configuration tests"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A05"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"SQL parameters, shape validation, text instead of HTML"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"payload tests, SAST (Semgrep, CodeQL)"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A06"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"threat modeling, limits in business flows"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"abuse cases in tests"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A07"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"attempt limits, MFA, secure sessions"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"login tests, DAST scan"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A08"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"SRI, signed artifacts, no deserialization of untrusted data"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"frontend dependency review"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A09"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"security events in logs, alarms"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"test: does an alarm arrive after 50 denials?"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"A10"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"fail closed, global error handling, no details for clients"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"tests with a dependency switched off (e.g. the permission service)"}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"common-mistakes"},"content":[{"type":"text","text":"Common mistakes"}]},{"type":"callout","attrs":{"variant":"danger","title":"Authorization only in the UI"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Hiding the \"Refund\" button from regular customers is UX, not security. Every endpoint checks permissions on the server – an attacker doesn't use your frontend, they use "},{"type":"text","text":"curl","marks":[{"type":"code"}]},{"type":"text","text":"."}]}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Input \"sanitization\" instead of output encoding","marks":[{"type":"bold"}]},{"type":"text","text":" – stripping "},{"type":"text","text":"<script>","marks":[{"type":"code"}]},{"type":"text","text":" from text doesn't protect against "},{"type":"text","text":"<img onerror>","marks":[{"type":"code"}]},{"type":"text","text":". Escape where the data enters HTML, SQL or a shell."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Address blocklists against SSRF","marks":[{"type":"bold"}]},{"type":"text","text":" – there's always a notation you didn't foresee (decimal, IPv6, a redirect). A host allowlist plus network controls."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A stack trace in a 500 response","marks":[{"type":"bold"}]},{"type":"text","text":" – a map of your application for the attacker."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"One scan before launch","marks":[{"type":"bold"}]},{"type":"text","text":" – dependencies and configuration change every week; scan in every pipeline."}]}]}]},{"type":"prosCons","attrs":{"pros":["a common language for developers, testers and auditors","a good checklist for code review and test planning","based on application testing data, CWE analysis and a community survey"],"cons":["it's a risk awareness list, not a complete standard – use OWASP ASVS for verification","it doesn't cover API-specific risks (separate list: API Security Top 10) or LLMs","it won't replace threat modeling for your specific system"],"prosTitle":"The OWASP Top 10 list","consTitle":"What it won't replace"}},{"type":"heading","attrs":{"level":2,"id":"test-yourself"},"content":[{"type":"text","text":"Test yourself"}]},{"type":"quiz","attrs":{"question":"`GET /api/orders/:id` requires login and uses UUIDs as identifiers. Is it secure?","multiple":false,"options":[{"text":"Yes – UUIDs can't be guessed","correct":false,"explanation":"Identifiers leak in links, logs and emails; this isn't access control."},{"text":"No, if the query doesn't check that the order belongs to the signed-in customer","correct":true,"explanation":"Yes – this is classic A01 (IDOR/BOLA)."},{"text":"Yes – login is enough","correct":false,"explanation":"Authentication says who you are, not what you can access."}]}},{"type":"quiz","attrs":{"question":"A React component renders a review with `dangerouslySetInnerHTML` because customers can bold text. What is the best fix?","multiple":false,"options":[{"text":"Remove the string `<script>` from the text","correct":false,"explanation":"A payload can use `<img onerror>`, `<svg onload>` and many other variants."},{"text":"Sanitize the HTML with DOMPurify using a tag allowlist (e.g. `b`, `i`) and add a CSP","correct":true,"explanation":"Yes – a tag and attribute allowlist plus a second line of defence."},{"text":"Replace `dangerouslySetInnerHTML` with `innerHTML` in `useEffect`","correct":false,"explanation":"It's the same vulnerability, just less visible."}]}},{"type":"details","content":[{"type":"detailsSummary","content":[{"type":"text","text":"Interview question: what changed in OWASP Top 10:2025 and what does it mean for a team?"}]},{"type":"detailsContent","content":[{"type":"paragraph","content":[{"type":"text","text":"A good answer names the two new categories: A03 Software Supply Chain Failures (extending the former vulnerable components category to the whole chain – dependencies, build systems, CI/CD, distribution) and A10 Mishandling of Exceptional Conditions (poor exception handling, fail-open, information leaks in errors). Further: SSRF is no longer a separate category and is part of A01 Broken Access Control, which is still number one; Security Misconfiguration moved up to second place. The practical conclusion: object-level authorization in every endpoint and tests with two accounts, supply-chain hygiene in the pipeline (lockfile, scanning, SBOM, pinned actions, OIDC instead of tokens), a fail-closed policy and consistent error handling, configuration as code with review. Bonus points for mentioning that OWASP ASVS is the verification standard, and APIs have a separate API Security Top 10."}]}]}]},{"type":"heading","attrs":{"level":2,"id":"what-s-next"},"content":[{"type":"text","text":"What's next"}]},{"type":"linkCard","attrs":{"url":"/en/articles/security-headers-and-csp","title":"Security headers and CSP","description":"A second line of defence against XSS and clickjacking","kind":"article","ref":"security-headers-and-csp"}},{"type":"linkCard","attrs":{"url":"/en/articles/api-security","title":"API security","description":"OWASP API Security Top 10, BOLA, JWT, rate limits and webhooks","kind":"article","ref":"api-security"}},{"type":"linkCard","attrs":{"url":"/en/articles/devsecops-pipeline","title":"DevSecOps pipeline","description":"SAST, SCA, SBOMs and threat modeling in CI/CD","kind":"article","ref":"devsecops-pipeline"}},{"type":"linkCard","attrs":{"url":"/en/topics/web-security","title":"OWASP Top 10 in practice","description":"Everything about web application security","kind":"topic","ref":"web-security"}}]},"toc":[{"id":"a01-broken-access-control-idor-and-ssrf","text":"A01 Broken Access Control: IDOR and SSRF","level":2,"locked":false},{"id":"a02-a04-a08-configuration-cryptography-and-integrity","text":"A02, A04, A08: configuration, cryptography and integrity","level":2,"locked":false},{"id":"a03-software-supply-chain-failures","text":"A03 Software Supply Chain Failures","level":2,"locked":false},{"id":"a05-injection-sql-nosql-and-xss","text":"A05 Injection: SQL, NoSQL and XSS","level":2,"locked":false},{"id":"xss-in-the-browser-try-it-yourself","text":"XSS in the browser – try it yourself","level":3,"locked":false},{"id":"a06-insecure-design-a-flaw-in-the-design-not-the-code","text":"A06 Insecure Design: a flaw in the design, not the code","level":2,"locked":false},{"id":"a07-authentication-failures","text":"A07 Authentication Failures","level":2,"locked":false},{"id":"a09-and-a10-logging-alerting-and-exceptional-conditions","text":"A09 and A10: logging, alerting and exceptional conditions","level":2,"locked":false},{"id":"cheat-sheet-one-control-per-category","text":"Cheat sheet: one control per category","level":2,"locked":false},{"id":"common-mistakes","text":"Common mistakes","level":2,"locked":false},{"id":"test-yourself","text":"Test yourself","level":2,"locked":false},{"id":"what-s-next","text":"What's next","level":2,"locked":false}],"locked":false,"paywall":null,"previewRatio":0.3,"totalBlocks":59,"visibleBlocks":59,"resources":[{"id":"6b0857bb3c96f2d34d0b3f8b","type":"podcast","provider":"apple-podcasts","url":"https://podcasts.apple.com/us/podcast/your-developers-are-the-attack-surface-now-and/id1537003676?i=1000773867894","embedUrl":"https://embed.podcasts.apple.com/us/podcast/id1537003676?i=1000773867894","title":"Your developers are the attack surface now and vibe coding as a vulnerability | Tanya Janca","description":"Developers are like water: if you make your security protocols too difficult, they will find a way to flow right around them. This week on Dev Interrupted, bestselling author and OWASP Top 10 Project Leader Tanya Janca returns to unpack why vibe coding has officially made the list of the most…","author":"Dev Interrupted","thumbnailUrl":"https://is1-ssl.mzstatic.com/image/thumb/Podcasts221/v4/c4/0b/27/c40b27a0-414c-3f21-15b1-1e98b078c944/mza_2205265202769372266.jpg/600x600bb.jpg","durationSec":2766,"lang":"en","topics":["ai-coding-assistants"],"techs":["general"],"tags":["podcast","security","ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"itunes","publishedAt":"2026-06-23T10:00:00.000Z","popularity":49,"verifiedAt":"2026-11-26T11:07:09.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:57.868Z","updatedAt":"2026-11-26T16:00:57.868Z"},{"id":"6b0857c83c96f2d34d0b49ed","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=AbW15XaKWIA","embedUrl":"https://www.youtube-nocookie.com/embed/AbW15XaKWIA","title":"Bezpieczeństwo w IT - Security Champions","description":"Kim są Security Champions i dlaczego ta rola staje się tak ważna w świecie IT? W tym odcinku Materiału Eksperckiego z 7N rozmawiamy z Bartoszem Różańskim, konsultantem 7N, jednym z głównych działaczy w ramach Warszawskiej grupy.NET, który od lat wdraża programy bezpieczeństwa w organizacjach…","author":"justjoinit","thumbnailUrl":"https://i.ytimg.com/vi/AbW15XaKWIA/hqdefault.jpg","durationSec":null,"lang":"pl","topics":[],"techs":["dotnet"],"tags":["security"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2025-10-02T07:42:12.000Z","popularity":59,"verifiedAt":"2026-11-26T11:14:57.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"id":"6b0857c43c96f2d34d0b4753","type":"book","provider":"openlibrary","url":"https://openlibrary.org/works/OL19543758W","embedUrl":null,"title":"Agile Application Security: Enabling Security in a Continuous Delivery Pipeline","description":"","author":"Laura Bell, Michael Brunton-Spall, Rich Smith, Jim Bird","thumbnailUrl":"https://covers.openlibrary.org/b/id/8510263-L.jpg","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["book","security","devops"],"price":"paid","featured":false,"featuredOrder":0,"packageName":null,"source":"openlibrary","publishedAt":"2017-01-01T00:00:00.000Z","popularity":31,"verifiedAt":"2026-11-26T11:00:08.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:07.480Z","updatedAt":"2026-11-26T16:01:07.480Z"},{"id":"6b0857c83c96f2d34d0b49ee","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=3611y9h-U-0","embedUrl":"https://www.youtube-nocookie.com/embed/3611y9h-U-0","title":"Building Secure Microservices in Azure - Jimmy Bogard - NDC London 2023","description":"Building microservices can be easy, but securing them is hard. We have external and internal applications, APIs, queues, users, and more. Each might use a different authentication and authorization strategy, depending on customer and system needs. The stakes are high and there is no margin for…","author":"NDC Conferences","thumbnailUrl":"https://i.ytimg.com/vi/3611y9h-U-0/hqdefault.jpg","durationSec":null,"lang":"en","topics":["microservices"],"techs":["general"],"tags":["cloud","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2023-05-14T15:00:02.000Z","popularity":59,"verifiedAt":"2026-11-26T11:13:14.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"}],"challenges":[],"attachments":[],"hasCode":true,"repoUrl":null,"series":[],"prev":null,"next":null,"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":104,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Authority","articles":90},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Authority","articles":61},{"key":"python","title":"Python","level":5,"levelLabel":"Authority","articles":59},{"key":"java","title":"Java","level":5,"levelLabel":"Authority","articles":46}]}}