Which of the following best describes an Injection attack as listed in the OWASP Top 10?
Think about how attackers might trick a program into doing something it shouldn't by sending unexpected input.
Injection attacks happen when untrusted data is sent to an interpreter as part of a command or query, causing the interpreter to execute unintended commands or access data.
Consider this Python code snippet that constructs an SQL query unsafely:
user_input = "' OR '1'='1'"
query = f"SELECT * FROM users WHERE username = '{user_input}'"
print(query)What is the printed output?
user_input = "' OR '1'='1'" query = f"SELECT * FROM users WHERE username = '{user_input}'" print(query)
Look carefully at how the user input is inserted into the query string.
The user input includes SQL code that closes the string and adds an OR condition that is always true, which can lead to unauthorized data access.
You want to write a test to check if a web application properly locks an account after 5 failed login attempts to prevent Broken Authentication.
Which assertion best verifies this behavior?
Think about what status code and message indicate the account is locked.
A 403 Forbidden status with a message about account lockout confirms the application blocks access after too many failed attempts, preventing broken authentication.
Given this test code snippet checking HTTP headers for security:
response = client.get('/login')
assert 'X-Frame-Options' in response.headers
assert response.headers['X-Frame-Options'] == 'DENY'
assert 'Content-Security-Policy' in response.headers
assert response.headers['Content-Security-Policy'] == "default-src 'self'"
assert 'Server' not in response.headersWhich assertion will fail if the server reveals its software version in the headers?
response = client.get('/login') assert 'X-Frame-Options' in response.headers assert response.headers['X-Frame-Options'] == 'DENY' assert 'Content-Security-Policy' in response.headers assert response.headers['Content-Security-Policy'] == "default-src 'self'" assert 'Server' not in response.headers
Check which header reveals server information.
The 'Server' header reveals software version and should be hidden to avoid security misconfiguration. If present, the assertion fails.
You want to automate tests for OWASP Top 10 vulnerabilities using a testing framework. Which approach best ensures coverage of Cross-Site Scripting (XSS) vulnerabilities?
Think about how XSS attacks work and how to detect them in tests.
XSS attacks inject malicious scripts into web pages. Testing involves inputting scripts and verifying the application properly escapes or sanitizes them to prevent execution.