Intermediate Cybersecurity Interview Questions
Cybersecurity interview questions for practitioners: SQL injection, XSS, CSRF, IDOR, password hashing, OAuth and OpenID Connect, JWT verification, SIEM triage, IOCs and the incident response lifecycle. Each answer explains why the other options are wrong.
CoversAccess controlCryptographyDetectionIdentityIncident responseOAuthOWASPPasswordsSOCThreat intelligenceWeb security
Practice questions with answers
Tap an option: green is right, red is wrong, and the explanation says why.
What is the most effective fix for SQL injection?
Show answer and explanation
Answer: B. Parameterised queries (prepared statements), so user input is always sent as data and never as SQL
SQL injection happens when input is concatenated into a query and changes its structure. With parameterised queries the SQL is fixed and values are bound separately, so ' OR 1=1 -- is just a strange name, not code. Least-privilege database accounts limit damage if something slips through. Hiding errors only slows attackers down, keyword blocklists are easily bypassed and break legitimate input, and the database password is irrelevant to injection.
A user can view another customer's invoice by changing /invoices/1001 to /invoices/1002 in the URL. What is this vulnerability?
Show answer and explanation
Answer: D. Insecure direct object reference (IDOR), a form of broken access control: the server doesn't check the invoice belongs to the user
Broken access control is at the top of the OWASP Top 10. The fix is an authorisation check on the server for every request: does this invoice belong to the signed-in account? Unguessable IDs (such as UUIDs) make enumeration harder but are not a fix on their own. Nothing here injects script, overloads the service or weakens encryption; the attacker simply asks for an object they shouldn't have, and the server hands it over.
How do you prevent stored cross-site scripting (XSS)?
Show answer and explanation
Answer: D. Encode output for the context it's placed in (HTML, attribute, JavaScript), sanitise any HTML you must allow, and add a Content Security Policy
Stored XSS happens when attacker-supplied text, such as a comment, is later rendered as live HTML or script in other users' browsers. Context-aware output encoding (which modern frameworks such as React do by default) turns it back into harmless text; when rich HTML is required, a proven sanitiser removes dangerous elements; and a strict CSP limits what injected script can do. Encryption and HTTPS protect data in storage and transit, not what the browser executes, and moving data to a cookie doesn't change how it renders.
Which defence most directly stops cross-site request forgery (CSRF) against a cookie-based session?
Show answer and explanation
Answer: D. SameSite cookies plus anti-CSRF tokens (or checking the Origin header) on state-changing requests
In CSRF a malicious site makes the victim's browser send a request to your site, and the browser attaches the session cookie automatically. SameSite=Lax or Strict stops cookies on most cross-site requests, and a secret per-session token (or a strict Origin check) proves the request came from your own pages. HttpOnly stops JavaScript reading the cookie, which helps against XSS, not CSRF. Password length and disabling JavaScript don't address forged requests.
Why should passwords be stored with Argon2, bcrypt or scrypt instead of a single SHA-256 hash?
Show answer and explanation
Answer: D. They are deliberately slow and memory- or cost-tunable with built-in salts, which makes guessing billions of passwords impractical
SHA-256 is designed to be fast, so a stolen database of SHA-256 password hashes can be attacked with billions of guesses per second on GPUs. Password-hashing functions add a work factor (and Argon2 a memory cost) that makes each guess expensive, and they handle salts for you. SHA-256 isn't reversible, its length isn't the issue, and none of these let anyone read passwords back, which is the point.
How do OAuth 2.0 and OpenID Connect (OIDC) differ?
Show answer and explanation
Answer: B. OAuth 2.0 is for delegated authorisation (an access token to call an API); OIDC adds authentication on top with an ID token that says who the user is
OAuth lets an app act on a user's behalf ("let this app read my calendar") without sharing the password, by issuing access tokens for APIs. It was never meant to say who the user is, and misusing access tokens for login has caused real breaches. OpenID Connect is a layer on OAuth that issues an ID token with verified identity claims, which is what "Sign in with Google" uses. They are distinct, OIDC works everywhere, and neither hashes passwords.
What must an API do when it receives a JWT access token?
Show answer and explanation
Answer: B. Verify the signature with the expected algorithm and key, and check the expiry, issuer and audience before trusting any claim
A JWT's payload is only Base64url-encoded, so anyone can create one; the signature is what makes it trustworthy. Servers must pin the allowed algorithm (never accept none or let the token choose), verify with the right key, and reject tokens that are expired or issued for another audience. Logging full tokens leaks working credentials. Many real vulnerabilities come from libraries or code that skipped one of these checks.
A SOC analyst sees an alert for a possible brute-force attack on a VPN. What should happen first?
Show answer and explanation
Answer: C. Triage: check the logs for scale, source, targeted accounts and whether any login succeeded, then decide whether to escalate and contain
Triage turns an alert into a decision. Look at how many attempts, from which IPs, against which accounts, and above all whether any attempt succeeded, which turns noise into an incident. Then enrich (is the IP known-bad, is the account privileged?), and contain proportionately: block the source, lock or reset the targeted account, require MFA. Shutting everything down is disproportionate, ignoring a possible success is how breaches begin, and contacting attackers is never the first step.
What does a SIEM do in a security operations centre?
Show answer and explanation
Answer: A. Collects and normalises logs from many sources, correlates events with detection rules, and raises alerts for analysts to investigate
A security information and event management platform centralises logs from endpoints, servers, firewalls, identity providers and cloud services, so analysts can search across them and correlation rules can spot patterns no single log shows, such as a login from a new country followed by mass file access. It detects and supports investigation; blocking is done by firewalls and EDR. A SIEM produces alerts that people (and increasingly SOAR automation) must handle, and encryption isn't its purpose.
What is the difference between an indicator of compromise (IOC) and an indicator of attack (IOA)?
Show answer and explanation
Answer: B. An IOC is evidence of a known bad artefact, such as a hash, IP or domain; an IOA is behaviour that shows an attack in progress, whatever tools are used
IOCs are specific and easy to share, but attackers change hashes, IPs and domains cheaply, so IOC matching mostly catches known campaigns. IOAs describe intent and technique, for example an Office document spawning PowerShell that downloads a payload, which stays detectable even when the artefacts change. Mature detection uses both, and behaviour-based detections are usually more durable. IOAs aren't signatures, and neither term is about physical security.
Take it as a timed test
- 12 questions
- 15 min
- Pass mark 60%
- Answers shown at the end
Sign in with your email to take the test: we send a 6-digit code, no password. Your scores and reports are saved to your account. The test also uses 10 questions that aren't shown above, so practise for understanding, not memory.
About this paper
This intermediate paper is for developers, analysts and engineers with some hands-on security experience. It covers how the most common web attacks work and how they are actually fixed (SQL injection, XSS, CSRF and broken access control), how passwords and tokens should be handled, how OAuth differs from OpenID Connect, and how a SOC turns a flood of alerts into a handful of real incidents. Ten questions are on this page with explanations. Each timed test draws 12 questions from a larger bank, including ones that aren't shown here, so every attempt is different.
Interviewers at this level often add "how would you detect it?" to each question, so read the explanations for the detection and the fix, not only the definition.