Web Application Security
Web Application Security
com
March 2025
The Basics of Web
Application Security
Common vulnerabilities and best practices for prevention
What is Web Application Security
Web Application Security
Web application security refers to the protective methods used
for web applications. These are processes, strategies, and
security measures designed for their protection.
Because of the OR 1=1 statement, the WHERE clause returns the first id from the users table
no matter what the username and password are. The first user id in a database is very often
the administrator. In this way, the attacker not only bypasses authentication but also gains
administrator privileges
Ways to Prevent SQL Injection
● The only sure way to prevent SQL Injection attacks is input validation and
parameterized queries including prepared statements. e.g.,
$username = filter_var($_POST['username'], FILTER_SANITIZE_STRING);
● The application code should never use the input directly. The developer must
sanitize all input, not only web form inputs such as login forms.
● They must remove potential malicious code elements such as single quotes.
● It is also a good idea to turn off the visibility of database errors on your
production sites.
Cross Site Scripting (XSS) Attacks
➢ Cross-site scripting (XSS) is an exploit where the attacker attaches code onto a
legitimate website that will execute when the victim loads the website.
➢ An attacker can use XSS to send a malicious script to an unsuspecting user.
The end user’s browser has no way to know that the script should not be
trusted, and will execute the script.
➢ The malicious script can access any cookies, session tokens, or other
sensitive information retained by the browser and used with that site.
Let’s analyze a simple Example: Consider we have a website with a search field.
If the search field is vulnerable, when the user enters any script, then it will be
executed.
<script>alert(‘XSS’)</script>
Then after clicking on the “Search” button, the entered script will be executed
As you can see in the Example, the script typed
into the search field gets executed. However, a
more harmful script may be typed as well.
<body onload=alert(‘something’)>;
The malicious script should be sent through the vulnerable input form (For Example, the comment
field or review field). This way the appropriate script will be saved in the database and executed on
the page load or appropriate function calling.
<script>alert(document.cookie)</script>
DOM XSS
This occurs when the DOM environment is being changed, but the code remains the same.
In this Example, a DOM object is being created by the browser, where the document location
object will contain the appropriate string.This way the DOM environment is being affected.
Ways to Prevent XSS
To: Victim
Subject: A gift of flowers for you!
Hello victim,
We know your birthday is coming up and have a special gift for you. Just click here to receive it!
The link “click here” would lead to the forged URL shown above.
CSRF Attack Examples
In this case, the attacker would need to craft a <form> element with the forged request:
When the user submits the form, then illicit transfer will carried out
Preventing CSRF Attacks
By implementing robust security measures such as input validation, strong authentication protocols,
secure data transmission, and regular software updates, organizations can significantly reduce the
risk of cyber threats.
Embracing these practices not only protects sensitive data but also fosters trust with users and
stakeholders.
trusted engineering partner for digital transformation
Thank you!
Q&A