Back to Web App Security & OWASP Top 10
Web App Security & OWASP Top 10

How do you remediate Stored Cross-Site Scripting (XSS) and Broken Object Level Authorization (BOLA)?

Encode output, enforce CSP, and add server‑side object checks to eliminate stored XSS and BOLA.

G
Gaurav Bhasin 👑 Tier 3 Elite
Aug 9, 2026 · 2 min read
Remediate stored XSS by applying context‑aware output encoding at the point of rendering and by enforcing a strict Content‑Security‑Policy; fix BOLA by implementing server‑side authorization checks that validate the caller’s rights against the specific object ID. **Remediation checklist** 1. **Input handling** – Reject or sanitize dangerous characters on entry (e.g., use `express-validator` in Node or `django.forms` clean methods). Do not rely on client‑side validation. 2. **Output encoding** – Encode data based on context: ```javascript // Node/Express with npm `xss-filters` const safe = require('xss-filters').inHTMLData(userInput); res.send(`
${safe}
`); ``` ```csharp // ASP.NET Core @HtmlEncoder.Default.Encode(userInput) ``` 3. **Content‑Security‑Policy** – Deploy a CSP that disallows `unsafe-inline` and restricts script sources: ```http Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.example.com; object-src 'none'; ``` 4. **HTTP‑Only & Secure cookies** – Set `HttpOnly; Secure; SameSite=Strict` to mitigate session theft. 5. **BOLA enforcement** – Before any object operation, fetch the object’s owner or ACL and compare it to the authenticated principal: ```python # Django view obj = MyModel.objects.get(pk=obj_id) if obj.owner_id != request.user.id: raise PermissionDenied() ``` Or with OPA: ```rego allow { input.method = "GET" input.path = ["api","orders", order_id] data.authz[subject].orders[order_id] == "read" } ``` 6. **Audit & testing** – Run automated scans (e.g., OWASP ZAP, Burp Suite) and include unit tests that assert `403` on unauthorized object IDs. **Gotcha:** Rendering user‑generated HTML via `innerHTML` or server‑side templating functions that bypass the encoder will re‑introduce XSS even with a CSP in place. Use a safe DOM API (`textContent`) or a sanitization library like DOMPurify.

Read the evidence

Sources used in this thread

Open the original material, compare the claims, and form your own view.

Community notes

Add context, not noise (0)

Corrections, lived experience, useful examples, and better sources belong here.

Nothing added yet. Be the first to make this thread more useful.
Click here to write a reply...
🔒

Authentication Required

Join Trendzza to begin your journey. Submit tasks, complete batches, help peers, and earn your way to Tier 3.