If a trusted developer wrote everything and you protect it the way you do the rest of your HTML page, then no.
But even if it is JavaScript written by trusted developers, if it is served via HTTP, then an attacker can modify it in flight, because HTTP through a free wireless network is often susceptible to MITM .
This can be used to effectively set the keylogger in the current browser window, to steal user passwords, redirect them to phishing pages, etc.
An attack can work as follows:
- The webpage performs a GET up to
http://example.com/foo.js . - The attacker modifies
foo.js mid-flight to add the JavaScript that window.addEventListener("keypress", /* a keylogger that sends all keys to evil.com cross domain by image loading tricks */) - The browser loads the modified JavaScript.
- The user enters the password in
<input type=password> . - Evil wins.
Since HTTPS (in the absence of mixed content) is not sensitive to MITM, it is not vulnerable to this attack.
Mike samuel
source share