Cybersecurity Interview Questions and Answers
Last updated 2026-11-19
Cybersecurity interviews start with fundamentals and then test judgement: given a scenario, what is the risk, what control would you apply and what is the trade-off? This page gives 16 worked answers across cryptography, web application security, identity, network defence, risk and incident response. Where it helps, there are short code or command examples, such as hashing passwords properly or reading a TLS handshake.
Everything here is defensive knowledge, and any hands-on testing must be done only on systems you own or have written permission to test. For networking depth see the network security questions, and for the offensive side the ethical hacking questions and SOC analyst questions.
| Core areas | Cryptography, network security, application security, IAM, risk, incident response |
|---|---|
| Frameworks to name | NIST CSF, ISO 27001, MITRE ATT&CK, OWASP Top 10, CIS Controls |
| Entry certifications | CompTIA Security+, then CEH, CISSP (experience required) or vendor certificates |
How to structure a security answer
For scenario questions, name the asset, the threat, the vulnerability and the control, then say how you would verify it works and what residual risk remains. For example, with a customer database: the threat is theft through SQL injection, the vulnerability is string-built queries, the control is parameterised queries plus least-privilege database accounts, verification is a code review and automated test, and the residual risk is a stolen credential. This shows layered thinking rather than a single magic fix.
Cybersecurity Interview Questions and Answers: questions with worked answers
1 Explain the CIA triad with an example of each being violated.
easyConfidentiality means only authorised parties can read data; it is violated when a misconfigured storage bucket exposes customer records. Integrity means data is accurate and unaltered; it is violated when an attacker modifies a payment destination in transit or a database row. Availability means systems are usable when needed; it is violated by ransomware or a DDoS attack. Controls map to each: encryption and access control for confidentiality, hashing, signatures and change control for integrity, redundancy, backups and rate limiting for availability. Many incidents hit more than one, and designing a control for one can weaken another, for example heavy encryption affecting performance.
2 What is the difference between symmetric and asymmetric encryption, and how does TLS combine them?
mediumSymmetric encryption, such as AES, uses one shared key and is fast, but distributing the key securely is hard. Asymmetric encryption, such as RSA or elliptic curve schemes, uses a public and private key pair, solving key distribution and enabling digital signatures, but is much slower. TLS uses asymmetric cryptography, or in TLS 1.3 an ephemeral Diffie-Hellman exchange, to authenticate the server through its certificate and agree on session keys, then uses a symmetric AEAD cipher such as AES-GCM or ChaCha20-Poly1305 for the data. Ephemeral key exchange gives forward secrecy: stealing the server's private key later cannot decrypt recorded traffic.
bashopenssl s_client -connect example.com:443 -tls1_3 -servername example.com </dev/null 2>/dev/null | grep -E 'Protocol|Cipher|Verify return' openssl x509 -in cert.pem -noout -subject -issuer -dates3 What is the difference between hashing, encryption and encoding? How should passwords be stored?
easyEncoding such as Base64 is reversible by anyone and offers no security. Encryption is reversible with a key. Hashing is one-way: the same input gives the same fixed-size output and you cannot recover the input. Passwords should never be encrypted or stored with a fast hash such as MD5 or plain SHA-256. Use a slow, salted, memory-hard password hashing function: Argon2id, scrypt or bcrypt, with a unique random salt per user and a tuned work factor. Compare with a constant-time function. Add rate limiting and multifactor authentication for the account itself.
python# pip install argon2-cffi from argon2 import PasswordHasher from argon2.exceptions import VerifyMismatchError ph = PasswordHasher() # Argon2id with sane defaults stored = ph.hash('correct horse battery staple') try: ph.verify(stored, 'correct horse battery staple') print('ok') except VerifyMismatchError: print('wrong password')4 Explain SQL injection, how to prevent it, and why escaping alone is weak.
mediumSQL injection occurs when untrusted input is concatenated into a query so the input is interpreted as SQL, for instance a username of ' OR '1'='1 changing the WHERE logic. The fix is parameterised queries (prepared statements), where the query structure is sent separately from the values so the database never parses data as code. Complement it with least-privilege database accounts, input validation by allow-list, avoiding dynamic SQL, and ORMs used correctly. Manual escaping is fragile because rules differ by database and character set and one missed path reintroduces the bug. Identifiers such as column names cannot be parameterised, so allow-list them.
pythonimport sqlite3 conn = sqlite3.connect('app.db') user_input = "alice' OR '1'='1" # vulnerable: string building # conn.execute(f"SELECT * FROM users WHERE name = '{user_input}'") # safe: parameterised rows = conn.execute('SELECT id, name FROM users WHERE name = ?', (user_input,)).fetchall()5 Describe XSS and CSRF and how each is mitigated.
mediumCross-site scripting injects attacker-controlled script into a page viewed by others, which then runs with the site's privileges, stealing sessions or performing actions. Mitigate with context-aware output encoding, a templating engine that escapes by default, avoiding innerHTML with untrusted data, and a Content Security Policy as defence in depth; HttpOnly cookies stop script reading the session cookie. Cross-site request forgery tricks a logged-in user's browser into sending a state-changing request to a site that trusts the cookie. Mitigate with anti-CSRF tokens, SameSite cookies (Lax or Strict), and checking Origin headers. XSS can defeat CSRF tokens, so fix XSS first.
6 What is in the OWASP Top 10 and which items matter most in practice?
mediumThe list ranks the most critical web application risks; the 2021 edition includes broken access control (first), cryptographic failures, injection, insecure design, security misconfiguration, vulnerable and outdated components, identification and authentication failures, software and data integrity failures, security logging and monitoring failures, and server-side request forgery. Broken access control matters most in practice: missing authorisation checks let users read others' records by changing an ID, known as IDOR. Prevent it by enforcing authorisation on the server for every request, denying by default and testing it. OWASP updates the list periodically, so mention you would check the current edition.
7 Explain authentication versus authorisation, and describe OAuth 2.0 and OpenID Connect.
mediumAuthentication proves who you are; authorisation decides what you may do. OAuth 2.0 is an authorisation framework that lets an application obtain limited access to a resource on a user's behalf through tokens, without sharing the password; the authorisation code flow with PKCE is the recommended flow for web and mobile apps. OpenID Connect adds an identity layer on OAuth, issuing an ID token (a JWT) that tells the app who authenticated. Security points: validate token signature, issuer, audience and expiry, use short-lived access tokens with refresh tokens, store tokens safely, and never use the implicit flow for new applications.
8 What is zero trust, and how does it differ from perimeter security?
mediumPerimeter security trusts anything inside the network boundary, so a single compromised laptop can roam freely. Zero trust assumes no implicit trust based on network location: every request is authenticated, authorised and encrypted using identity, device posture and context, access is least privilege and time-bound, and the network is segmented so breaches are contained. Practical building blocks are strong identity with MFA, device compliance checks, micro-segmentation, identity-aware proxies in place of broad VPN access, and continuous monitoring. It is an architecture direction adopted incrementally, not a product you buy.
9 How do firewalls, IDS and IPS differ, and where do WAFs fit?
easyA firewall enforces allow and deny rules on traffic by address, port and protocol; next-generation firewalls add application awareness and inspection. An intrusion detection system monitors a copy of traffic or logs and alerts, while an intrusion prevention system sits inline and can block. Detection can be signature-based, which is accurate for known attacks, or anomaly-based, which can find new behaviour but produces false positives. A web application firewall understands HTTP and filters attacks such as SQL injection and XSS aimed at web apps; it is a compensating control and not a substitute for fixing the code. Place them in layers, with logs going to a central SIEM.
10 Walk through the incident response lifecycle.
mediumThe NIST lifecycle has four phases. Preparation: policies, playbooks, tooling, logging and trained people. Detection and analysis: triage alerts, confirm an incident, scope the affected systems and rate severity. Containment, eradication and recovery: isolate affected hosts or accounts without destroying evidence, remove the attacker's access and malware, restore from known-good backups and monitor closely for reinfection. Post-incident activity: a blameless review, lessons learned and control improvements. Preserve volatile evidence and keep a chain of custody if legal action is possible, and follow notification obligations such as reporting rules for personal-data breaches.
11 What is risk, and how do you calculate and treat it?
mediumRisk is the likelihood of a threat exploiting a vulnerability multiplied by the impact on an asset. Qualitative scoring uses levels such as low, medium and high; quantitative scoring estimates annualised loss expectancy as single loss expectancy times annual rate of occurrence, so a 2,00,000 rupee loss occurring once in four years gives 50,000 rupees per year, which sets a ceiling on how much a control is worth spending. Treatments are mitigate, transfer (insurance or outsourcing), avoid, or accept with documented sign-off. Keep a risk register with owners, review it regularly and prioritise by risk, not by which vulnerability scanner colour is scariest.
12 What are the common types of malware and how does ransomware typically unfold?
mediumViruses attach to files and need execution to spread, worms self-propagate across networks, trojans masquerade as legitimate software, rootkits hide themselves, spyware and keyloggers steal information, and ransomware encrypts data for payment. A typical ransomware intrusion starts with phishing, an exposed remote service or stolen credentials, then the attacker escalates privileges, moves laterally, steals data for double extortion, deletes backups and finally encrypts. Defences: patching, MFA on remote access, email filtering, least privilege, network segmentation, endpoint detection and response, and offline or immutable backups that are tested for restore. Decisions about paying should involve legal and law enforcement, not be made alone.
13 What is the principle of least privilege and how do you apply it on a Linux server?
easyEvery user, process and service should have only the access required for its task and no more. On Linux, use dedicated unprivileged service accounts, restrict sudo to specific commands, set file permissions tightly, use group ownership instead of world-readable files, drop capabilities and run services in containers or with systemd sandbox options, and disable password SSH login in favour of keys. Audit regularly for SUID binaries and world-writable files. The same principle applies to cloud roles and database accounts.
bashfind / -perm -4000 -type f 2>/dev/null find /var/www -type f -perm -o+w 2>/dev/null sudo sshd -T | grep -E 'passwordauthentication|permitrootlogin'14 What is a man-in-the-middle attack, and how do HTTPS and HSTS help?
mediumIn a man-in-the-middle attack an adversary positions themselves between two parties, for example on rogue Wi-Fi or through ARP or DNS spoofing, to read or alter traffic. HTTPS with valid certificates gives encryption and server authentication, so intercepted traffic is unreadable and tampering is detected, provided the user does not click through certificate warnings. HSTS tells browsers to use HTTPS only for a domain for a set period, defeating downgrade and SSL stripping attacks, and preload lists protect even the first visit. Certificate pinning and mutual TLS strengthen mobile and service-to-service links.
15 What is the difference between vulnerability assessment and penetration testing?
easyA vulnerability assessment is a broad, mostly automated scan that lists known weaknesses with severities, such as missing patches and insecure configurations, and is repeated regularly. A penetration test is a goal-driven, manual and time-boxed exercise where testers chain weaknesses the way an attacker would to prove real impact, such as reaching domain admin or customer data, under a signed scope and rules of engagement. Assessments give breadth and tracking; tests give depth and evidence of exploitability. Findings from both should flow into a prioritised remediation process.
16 How would you secure a CI/CD pipeline and software supply chain?
hardTreat the pipeline as a high-value target. Pin dependencies with lockfiles and verify integrity, scan dependencies and containers for known vulnerabilities, and generate a software bill of materials. Use short-lived credentials through OIDC, never long-lived secrets in repositories, and restrict who can modify pipeline definitions. Require code review and branch protection, sign artefacts and verify signatures before deployment, build in ephemeral isolated runners, and pin third-party actions to commit hashes. Monitor for typosquatted packages and unexpected install-time scripts.
17 A user reports a suspicious email asking them to log in. What do you do?
mediumAsk whether they clicked or entered credentials, and treat it as an incident if so. Get the original message as an attachment to preserve headers, then analyse the sender, SPF, DKIM and DMARC results, link destinations (without clicking, using a sandbox or URL scanner) and attachments. If malicious, search the mail system for the same message across mailboxes and purge it, block the sender and domain, add the URL to the proxy blocklist and check logs for anyone who visited it. If credentials were entered, reset the password, revoke sessions and tokens, check for suspicious mailbox rules and MFA changes, and watch for sign-ins from unusual places. Finally, report back to the user and use it as awareness training.
Frequently asked questions
What should a fresher learn first for cybersecurity?
Networking fundamentals (TCP/IP, DNS, HTTP, TLS), Linux basics, how web applications work and common web vulnerabilities, then one area such as blue team monitoring or application security. Practise in legal labs such as intentionally vulnerable apps.
Is coding required for cybersecurity jobs?
Scripting in Python or Bash is expected for most roles, to automate analysis and parse data. Application security and security engineering roles need stronger programming skills.
Which certification is best to start with?
CompTIA Security+ is a common first certificate for fundamentals. CEH is well known in India for ethical hacking roles, and CISSP is for experienced professionals. Hands-on labs and projects often matter more to interviewers.
What is the difference between red team, blue team and purple team?
Red teams emulate attackers to test defences, blue teams detect and respond, and purple teaming has both collaborate so each attack technique results in improved detection.
Related guides
More in Role-wise Interview Questions by Job and Tech Stack
- Data Analyst Interview Questions and Answers
- Data Engineer Interview Questions and Answers
- Data Scientist Interview Questions and Answers
- Deep Learning Interview Questions and Answers
- DevOps Interview Questions and Answers
- Django Interview Questions and Answers (Django 5)
- Docker Interview Questions and Answers
- Ethical Hacking Interview Questions and Answers
- ETL and Data Warehousing Interview Questions and Answers
- Excel Interview Questions and Answers
- Express.js Interview Questions and Answers (Express 5)
- FastAPI Interview Questions and Answers