CREST Secure Coding & Application Security 1 — Questions and Answers
Question 1: What is SQL injection and how is it primarily prevented?
- It inserts malicious SQL into queries; prevented by using parameterized queries or prepared statements (Correct answer)
- It overflows a database buffer; prevented by input length limits
- It encrypts database queries; prevented by disabling encryption
- It replays old database transactions; prevented by session tokens
Correct answer: It inserts malicious SQL into queries; prevented by using parameterized queries or prepared statements
SQL injection manipulates database queries by inserting malicious SQL via unsanitized input; parameterized queries separate code from data, preventing the injection.
Question 2: Which OWASP Top 10 category covers security misconfigurations such as default credentials and open cloud storage buckets?
- A05: Security Misconfiguration (Correct answer)
- A01: Broken Access Control
- A03: Injection
- A07: Identification and Authentication Failures
Correct answer: A05: Security Misconfiguration
OWASP A05 Security Misconfiguration encompasses improperly configured security settings, default credentials, unnecessary features, and misconfigured cloud services.
Question 3: What is Cross-Site Scripting (XSS) and which type allows attackers to store malicious scripts on the server?
- XSS injects malicious scripts into web pages; stored XSS persists scripts on the server (Correct answer)
- XSS steals server-side session tokens; reflected XSS stores them
- XSS modifies HTTP headers; DOM XSS stores them in cookies
- XSS overwrites database records; blind XSS persists them
Correct answer: XSS injects malicious scripts into web pages; stored XSS persists scripts on the server
XSS injects client-side scripts into pages viewed by other users; stored (persistent) XSS saves the malicious script on the server so it executes for every visitor.
Question 4: What does CSRF (Cross-Site Request Forgery) exploit?
- A victim's authenticated session to make unauthorized requests on their behalf (Correct answer)
- A server-side code execution vulnerability
- An unvalidated redirect in web applications
- A weak session token generation algorithm
Correct answer: A victim's authenticated session to make unauthorized requests on their behalf
CSRF tricks an authenticated user's browser into sending forged requests to a web application, leveraging the user's existing session cookies without their knowledge.
Question 5: Which HTTP security header helps mitigate XSS attacks by restricting which sources of scripts are trusted?
- Content-Security-Policy (CSP) (Correct answer)
- X-Frame-Options
- Strict-Transport-Security
- X-Content-Type-Options
Correct answer: Content-Security-Policy (CSP)
The Content-Security-Policy header defines which origins are permitted to load scripts, styles, and other resources, blocking execution of injected inline scripts.
Question 6: What is an Insecure Direct Object Reference (IDOR) vulnerability?
- When an application exposes internal object references without access control checks, allowing unauthorized data access (Correct answer)
- When user input directly controls database queries
- When an application redirects users to untrusted external URLs
- When session tokens are predictable and can be guessed
Correct answer: When an application exposes internal object references without access control checks, allowing unauthorized data access
IDOR occurs when a user can directly reference internal objects (like user IDs in URLs) and access data they are not authorized to see because access control checks are absent.
What is SQL injection and how is it primarily prevented?