XMLHttpRequest, often shortened to XHR, is a browser mechanism used to send asynchronous requests from a web page to an API. In single-page applications, XHR traffic carries much of the application’s business logic, so security testing must inspect it to understand the true attack surface and authorisation behaviour.
What XHR Does in the Browser Request Path
XMLHttpRequest is a browser-side request mechanism, so its security meaning comes from how a page uses it to reach APIs. In single-page applications, XHR often carries business-critical reads and writes that never appear in a full-page navigation, which means the real application surface is the traffic and the server-side responses it triggers.
Because XHR is an execution path rather than a protocol boundary, security review needs to treat it as part of the application workflow. A harmless-looking button click can still produce a sensitive API call, and the request may carry cookies, bearer tokens, CSRF tokens, headers or parameters that matter more than the visible UI does.
Why XHR Changes the Attack Surface
XHR can expose functionality that is not obvious from the page layout. Attackers, testers and defenders all use it to uncover hidden endpoints, parameter tampering opportunities, overbroad object access and business logic that is only enforced in JavaScript or client-side routing.
That is why the browser console, network inspector and server logs all matter. The page may render one experience while XHR reveals a second layer of API behaviour, and security assumptions built only from HTML pages are often incomplete.
Because XHR is commonly used in authenticated sessions, it can also expose the trust boundary between browser and API. If an endpoint relies on the front end to enforce authorisation, or if an API accepts requests without strong server-side checks, the browser call becomes a direct path to misuse.
How Security Testing Should Inspect XHR Traffic
XHR inspection should focus on request structure, response content and the state changes each call can trigger. Testers typically compare different users, roles and session states to see whether the same request pattern behaves differently when access should be restricted.
This is especially important in modern JavaScript applications because the most sensitive operations are often API-driven rather than page-driven. OWASP API Security Top 10 is a useful companion reference for analysing broken authorisation, broken authentication and other API-layer failures that XHR may expose.
In practice, XHR review should also consider how server-side policy is enforced rather than how the interface is presented. A request that looks routine in the browser can still be the only thing standing between a user and a privileged action, which makes request replay and parameter manipulation especially valuable tests.
Security Consequences of Weak XHR Handling
When XHR endpoints are weakly protected, the main risks are unauthorized data access, broken workflow enforcement and unintended modification of back-end state. The issue is rarely XHR itself, but the fact that XHR can make hidden API dependencies easy to reach and easy to automate.
Weak handling also increases detection gaps. Since XHR traffic is normal browser traffic, malicious use can blend into everyday application activity unless logging, authorisation checks and anomaly detection are strong enough to distinguish expected from abusive patterns.
For that reason, controls such as access control, request validation and audit logging become materially important when XHR carries business logic. NIST SP 800-53 Rev 5 Security and Privacy Controls provides a relevant control catalogue for mapping those protections to authorisation, authentication, audit and configuration requirements.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP API Security Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP API Security Top 10 | API1 — Broken Object Level Authorization | XHR frequently exposes object-level API access that must be enforced server-side. |
| API2 — Broken Authentication | XHR often carries session or token-backed API calls whose authentication can fail independently of the UI. | |
| Recommendation — Check XHR-backed endpoints for object-level authorization bypasses and enforce server-side access checks. Validate that XHR requests are authenticated correctly and reject calls without strong session proof. | ||
| NIST SP 800-53 Rev 5 | AC-3 — Access Enforcement | XHR-driven API actions require server-side enforcement of what each session may do. |
| AU-2 — Event Logging | XHR activity is a high-value audit source for business actions and abuse detection. | |
| IA-2 — Identification and Authentication (Organizational Users) | XHR commonly operates inside authenticated browser sessions and depends on reliable user authentication. | |
| Recommendation — Enforce access decisions on every XHR-served action at the server boundary. Log XHR-backed security-relevant events so request abuse and misuse can be investigated. Require strong user authentication before exposing sensitive XHR-backed functions. | ||
Practitioner Guidance
Why practitioners should care: Treat XHR as a security testing target, not just a front-end implementation detail. The browser request often reveals the real API contract, the true authorisation logic and the business actions that matter most.
What to watch for: Focus on differences between users, roles and states, then check whether the same XHR can be replayed, modified or invoked outside the intended UI path. That is usually where hidden trust assumptions and overexposed functionality show up first.
Practitioner takeaway: If you can only see one application screen, you have not yet seen the application. Inspect XHR to understand what the server actually trusts.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 30, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org