OWASP 10 Guide for Developers
Ten 1-minute videos about each item in OWASP 10, no BS, just short and to the point. Let’s start developing securely from the first line of code.
Injection attacks are when malicious code is fed into the user interface to try and trick the interpreter into carrying out unintentional commands like accessing data without permission.
The most commonly seen attack of this type is SQL injection.
If an attacker enters the SQL expression of “KATE or 1=1 --” into the name field of a login form instead of just “KATE,” then the query will just return TRUE because of the “or 1 = 1”. The -- will truncate the original query, removing anything after it.
By doing so, the attacker could be successful in accessing sensitive data like passwords or payment details.
Injection attacks are also capable of executing OS commands, allowing an attacker to introduce new code into a system, a tactic sometimes used to obtain unauthorized admin access.
Here are a few things you can do to protect your code:
First, it’s important to validate user input for any attempt to inject code. Check for the accepted type, length, format, and so on.
Second, use Parametrized queries. This allows the database to distinguish between code and what the user input.
Or even better, use stored procedures. This is similar to Parametrized queries. They are queries that were precompiled by the database.
And lastly, avoid using administrative privileges to run queries.
Broken authentication happens when session management isn’t properly implemented. It allows an attacker to carry out credential stuffing, brute force access, and session hijacking against your web app. In the case of credential stuffing, automated tools can be used to test a list of stolen usernames and passwords in an attempt to compromise legitimate accounts. Compromises like this can open the door for fraud, money laundering, identity theft, and the loss of highly sensitive information.
There are several steps to preventing broken authentication. Multi-factor authentication can stop automated attacks such as credential stuffing and brute force attacks. Also, prevent users from using weak passwords and add rules to check password length, complexity, and how often they need to be changed. Finally, session management should be used to ensure sessionIDs are invalidated after logout or idle and a new random sessionID is generated at login and is not passed in the URL.
Sensitive data exposure is when an application doesn’t protect certain types of information from being leaked.
Sensitive information can be session tokens, passwords, banking information, health data, or really any data that could cause harm if it is exposed or leaks out.
As an example, as a developer, you may decide to use the default database encryption to encrypt credit cards, however the database automatically decrypted this data when it was retrieved. This means that if the attacker successfully uses SQL injection to retrieve credit card numbers, they will be in clear text.
To prevent this, start with identifying which data is sensitive and ensure you encrypt it at rest by using up to date encryption algorithms and proper key management. As for data in transit, secure it with protocols like TLS.
Also, avoid storing sensitive data if you don’t need it, including data in memory, or other caches within your environments, and remove it safely as soon as possible when you are done with it.
And lastly, never store passwords in clear text. Instead, use strong adaptive and salted hashing functions to prevent them from being stolen by an attacker.
Equip Your Dev Team With Secure Coding Training
Wizer For Developers includes:
- Owasp 10 To Advanced Techniques
- Deep-Dive 1 New Topic Monthly
-
Fun CTF Challenges to Apply Learning