JS Source Code Vulnerabilities
Unintended Script Execution
Exclusive Reliance on Client-Side Validation
Most organizations only ensure validation on users’ browsers. Though this offers a certain level of security, hackers who use advanced techniques to send unverified data to servers can corrupt records and configurations.
Exposure of Session Data
Attackers leverage the power of client-side browser scripts to access all communication between the browser and the web application. This communication may include sensitive session data, such as user session IDs used for unauthorized access.
Unintentional User Activity
These vulnerabilities include:
- Filtering & sanitizing user input
- Using effective response headers
- Encode data before output generation
- Utilize Content Security Policies
- Using regularly an XSS Scanner before every release
Cross-Site Request Forgery (CSRF or XSRF)
CSRF is a widespread security vulnerability in which threat actors manipulate legitimate users into submitting malicious requests to web applications they are ambushed to visit. When the web application fails to differentiate between valid user requests and forged requests, attackers can execute any malicious actions under the guise of legitimate end-users.
CSRF attacks can be prevented by:
- Implementing secure random tokens
- Logging off unused web applications
- Disallowing automatic password entries by browsers
- Securing session credentials
- Using regularly a CSRF Scanner before every release
This mechanism injects and executes malicious or arbitrary code on a web application’s server without sanitizing and filtering user inputs. Attackers typically look for functions that parse user-generated data without proper validations to ingest insecure scripts to be executed by the server.
Client-Side Logic Attacks
Client-Side Logic attacks can be prevented by avoiding operations with sensitive security controls on the client side.
Avoid Evaluating User Input – The eval() and new Function () command executes arguments passed in user inputs as JS expressions. As hackers manipulate user input to run malicious scripts, it is recommended to avoid evaluating user inputs or parsing JSON data through the above constructors.
Enable TLS/SSL Encryption – Encrypting data between servers and clients helps prevent CSRF and XSS attacks.
Secure API Access – It is essential to assign tokens for each user accessing the web app through the API, enabling secure access.
Setting Secure Cookies – By setting cookies as secure, each cookie can only be used for a single web page, ensuring encrypted access.
Defining Content Security Policies – Content security policies ensure that attackers don’t inject malicious scripts into web applications to manipulate state changes.
Also, hire security professionals or embed continuous security by employing a security scanner and generating a vulnerability report before pushing new production changes. You can read about DevSepOps and SecDevOps in our blog posts (and yes, they are different things).
The Zed Attack Proxy (ZAP) is an open-source web application security scanner part of the OWASP project. The tool uses a combination of AJAX Spidering and Fuzzing to expose potential vulnerabilities by sending the application into an undesired state. ZAP encapsulates most AppSec features in a single, open-source, easy-to-use platform that enables manual and automated security scans.
The Crashtest Security Suite is trusted by many software vendors and organizations globally to deploy safer web applications through vulnerability scanning and assessment. Start your 14-day trial with the suite to explore how Crashtest Security can help improve developer productivity and reduce security testing budgets.