Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› JavaScript Credential Harvesting
Cyber Security

JavaScript Credential Harvesting

← Back to Glossary
By NHI Mgmt Group Updated November 5, 2026 Domain: Cyber Security

A browser-side technique that captures usernames and passwords by injecting malicious script into a login page. In this article’s context, the script hooks form submissions on Outlook Web Access and sends captured credentials to an external channel, turning a normal sign-in page into an interception point.

How JavaScript Credential Harvesting Works

JavaScript credential harvesting turns a login form into a capture point by running malicious script in the browser and intercepting what the user submits. In practice, the attacker does not need to defeat the password field itself; they exploit the fact that the page’s own execution context can read form values before they are sent.

This makes the technique especially effective on webmail, single sign-on, and other high-value portals where users trust the page they see. The page can look legitimate while silently duplicating credentials to an external destination, which makes the attack hard to notice from the user’s perspective.

Why Browser-Side Interception Is Dangerous

The danger is not limited to one stolen username and password. Once the browser is executing attacker-controlled code on a login page, the script can capture credentials, session material, and sometimes additional form data, depending on what the page exposes and when the code runs. That creates a direct path from a normal sign-in event to account takeover.

Because the interception happens before or during submission, traditional perimeter controls may see only ordinary web traffic. The real weakness is trust in the page itself, not the transport. If the page has been modified, the browser becomes part of the attacker’s collection pipeline.

For defenders, this is why credential theft scenarios are often paired with broader credential harvesting detection work and browser-side compromise checks rather than relying on password policy alone.

How Organisations Check Exposure and Contain the Blast Radius

Exposure review starts with the affected application, its login flow, and any places where custom script can be injected or altered. Teams should verify whether the portal is internet-facing, whether content is delivered through a trusted build and deployment path, and whether any third-party scripts, extensions, or injected web content could alter the page at runtime.

Containment also depends on the value of the credentials at risk. If the login page protects email, admin consoles, cloud portals, or API access, the post-compromise impact can extend far beyond the initial user account. That is why organisations pair page integrity review with session review, credential rotation, and review of downstream access granted through the stolen sign-in.

Where the technique is used against webmail or similar services, guidance on credential lifecycle control and secrets management helps translate a browser-side theft into a wider containment plan.

Detection and Remediation After Suspected Harvesting

Detection should focus on both the page and the aftermath. On the page side, look for unexpected script changes, unfamiliar event handlers, altered form submission logic, and outbound requests that do not belong in the normal authentication flow. On the aftermath side, look for impossible travel, new mail rules, token abuse, or sign-ins that do not match the user’s usual behaviour.

Remediation usually needs to do more than remove the malicious script. The organisation should assume the exposed credentials may already be in use, invalidate active sessions where appropriate, and review connected accounts, delegated access, and any stored credentials that the attacker could reach after signing in. If the page was altered through a compromised host or supply-chain dependency, the review must extend beyond the login form itself.

Where code or package compromise is part of the path, the lessons in Shai Hulud npm malware campaign and the broader secret sprawl challenge are directly relevant to post-incident review.

Risk and Threat Considerations

JavaScript credential harvesting is dangerous because it abuses the one place users most trust, the login page itself. The attacker can capture secrets without needing to break encryption or bypass the password field, which makes the technique both stealthy and highly scalable when a single tampered page serves many users.

Failure mechanism: Malicious script runs in the browser context, hooks the form submission path, and copies credentials to an attacker-controlled channel before or during normal authentication.

Impact: Stolen credentials can enable immediate account compromise, mailbox access, session theft, lateral movement, and follow-on abuse of any systems protected by the same login flow.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK and OWASP API Security Top 10 address the attack and risk surface, while NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-2 — Identification and Authentication (Organizational Users)Covers login authentication where browser-side credential theft undermines user sign-in.
IA-5 — Authenticator ManagementApplies because harvested usernames and passwords require rotation, revocation, and lifecycle control.
Recommendation — Strengthen IA-2 to reduce the value of stolen browser-submitted credentials. Apply IA-5 to rotate exposed authenticators and revoke compromised access paths.
OWASP ASVSV6 — AuthenticationDirectly addresses secure authentication flows that the attack subverts in the browser.
Recommendation — Use V6 to verify that authentication handling resists client-side credential interception.
MITRE ATT&CKT1056 — Input CaptureMatches malware that records or intercepts user input and form submissions in the browser.
T1110 — Brute ForceStolen credentials from harvesting commonly feed follow-on authentication abuse.
Recommendation — Map observed form-hooking behaviour to T1056 and hunt for capture activity in affected sessions. Treat harvested credentials as input to credential abuse detections and response.
CIS Controls v8CIS-5 — Account ManagementCovers account lifecycle and revocation after credential theft and compromise.
Recommendation — Use CIS-5 to remove compromised access and reset affected accounts quickly.
OWASP API Security Top 10API2 — Broken AuthenticationRelevant where harvested credentials are used to defeat downstream API authentication and session controls.
Recommendation — Use API2 to harden authentication paths that accept stolen or replayed credentials.

Practitioner Guidance

Why practitioners should care: Treat login-page integrity as part of authentication security, not just front-end hygiene. If the page can be changed silently, the organisation can lose credentials even when the backend authentication stack remains intact.

What to watch for: Any authentication page that accepts unreviewed JavaScript, third-party embeds, or unexpected client-side changes deserves scrutiny. Pay special attention to portals that carry high-value sessions, because a single browser-side interception can rapidly turn into an enterprise-wide incident.

Practitioner takeaway: The most important control question is not only whether the password is strong, but whether the page that collects it can still be trusted.

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.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 5, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org