Cybersecurity Engineer Top 100 Interview Questions
100 cybersecurity engineer interview questions with structured answers, comparison tables, flow diagrams, worked calculations and runnable code. Covers security fundamentals, cryptography, network and application security, identity, detection, incident response and vulnerability management, from the basics to design and scenario questions.
Questions 1-20 of 100
Q1.What are confidentiality, integrity and availability, and how is each one attacked?
Confidentiality, integrity and availability are the three properties security protects: data is seen only by the right people, changed only in authorized ways, and reachable when it is needed. Almost every attack harms at least one of them, so the triad is a quick way to reason about impact.
Confidentiality Integrity Availability Only authorized parties can read data Data changes only in authorized ways Systems answer when needed Attacked by a stolen database export Attacked by a tampered payment amount Attacked by a denial-of-service flood Protected by encryption and access control Protected by hashes, signatures and input validation Protected by redundancy, rate limits and backups How to use it in practice:
- Rate an incident's impact on each property separately. Ransomware hits availability, and often confidentiality too when data is copied out before encryption.
- Watch for controls that trade one property for another. Strong encryption with no key backup protects confidentiality but can destroy availability.
- Many teams add authenticity (who sent it) and non-repudiation (the sender cannot deny it) as companion properties.
Interview tip: when you describe any control, say which of the three properties it protects; it shows you think in terms of impact rather than tools.
Q2.What is the difference between a vulnerability, a threat and a risk?
A vulnerability is a weakness, a threat is something that could exploit it, and risk is the likelihood and impact of that happening. A risk exists only where a threat can reach a vulnerability in an asset that matters.
Vulnerability Threat Exploit Risk A weakness in a system, process or person An actor or event that could cause harm The method or code that uses the weakness Likelihood times impact of the threat succeeding An unpatched web server A criminal group scanning for that flaw A public attack script for the flaw Customer data stolen, fines and lost trust Ways to lower a risk:
- Remove the vulnerability: patch the server or fix the code.
- Cut the threat's access: take the service off the internet or put it behind authentication.
- Reduce the impact: encrypt the data, segment the network and keep tested backups.
A simple working model is
risk = likelihood × impact. It explains why a severe flaw on an isolated test machine can matter less than a moderate flaw on an internet-facing payment system.Q3.What is defense in depth, and what does it look like for a web application?
Defense in depth means layering independent controls so that a single failure does not become a breach. Each layer assumes the one in front of it can be bypassed.
Edge Network Identity Web application firewall, rate limits Private subnets, tight firewall rules Multi-factor authentication, short sessions Stops known attack payloads and floods Stops direct access to servers and databases Stops account takeover Application Data Monitoring Input validation, output encoding, authorization checks Encryption, least-privilege database accounts Central logs, alerts, audit trails Stops injection, cross-site scripting and data access by the wrong user Stops bulk data theft Catches attacks that would go unnoticed What makes the layers effective:
- They fail in different ways. Two filters that use the same pattern list are one layer, not two.
- Each layer is owned and tested, not assumed. A firewall rule nobody reviews decays over time.
- Detection sits behind prevention, because prevention eventually fails.
- Layers cost money and add friction, so the deepest stack belongs in front of the most valuable data.
Example
One injection attempt walked through the layers of a shop's checkout service:
- An attacker encodes a database injection payload so that the firewall's pattern rules miss it.
- The application uses parameterized queries, so the payload is treated as data and the query is unchanged.
- Even if a query had been vulnerable, the service's database account can read only the orders table, so customer passwords stay out of reach.
- The burst of malformed requests from one address raises an alert, and the analyst blocks the source within minutes.
One layer failed, and the breach was still stopped by the next three.
Q4.What do least privilege and separation of duties mean in practice?
Least privilege gives every person and system only the access needed for its task, for only as long as it is needed. Separation of duties splits sensitive actions so that no single person can complete them alone.
Least privilege
- Grant access through roles or groups, not to individuals one by one.
- Use just-in-time elevation for administrative work: access is requested, approved, time-limited and logged.
- Give each service its own account, scoped to the exact resources it uses.
- Review access regularly and remove what has not been used.
Separation of duties
- The developer who writes a change should not be the only approver who releases it to production.
- The person who adds a new supplier should not also be able to approve payments to that supplier.
- Emergency "break-glass" accounts exist, but their use triggers an alert and a review.
Both principles limit the blast radius of a stolen account, an insider or a simple mistake. The trade-off is friction, so automate requests and approvals to keep work moving.
Q5.How do preventive, detective and corrective controls differ?
Controls are grouped by when they act: preventive controls stop an incident, detective controls notice one, and corrective controls limit the damage and restore normal service. A sound program uses all three, because prevention alone eventually fails.
Preventive Detective Corrective Stops the incident from happening Notices an incident during or after it Limits damage and recovers Multi-factor authentication, firewall rules, input validation Alerting on logs, file integrity monitoring, intrusion detection Restoring backups, patching, revoking credentials Deterrent Compensating Discourages the attempt Stands in when the main control is not possible Warning banners, visible monitoring Extra monitoring on a system that cannot be patched Controls are also classed by form:
- Administrative: policies, training and background checks.
- Technical: encryption, access control and logging.
- Physical: locks, badges and cameras.
When you assess a risk, check that it has at least one control of each timing type. A risk covered only by preventive controls has no plan for the day they fail.
Q6.How do you calculate the annualized loss expectancy of a risk?
Annualized loss expectancy estimates how much a risk costs per year on average: the loss from one occurrence multiplied by how often it is expected to occur.
SLE = asset value × exposure factorALE = SLE × ARO
What each term means:
- Asset value: what the asset is worth, including recovery work, fines and lost revenue, not only its purchase price.
- Exposure factor: the share of that value lost in one incident, from 0 to 1.
- SLE (single loss expectancy): the cost of one occurrence.
- ARO (annualized rate of occurrence): expected occurrences per year; once every four years is 0.25.
When to use it: to compare a risk with the cost of controlling it. A control is worth buying when its yearly cost is lower than the reduction in ALE it brings.
The inputs are estimates, so present the result as a range and record the assumptions. Its main value is making a cost-versus-benefit discussion concrete.
Example
A worked decision about protecting a customer database:
- Asset value is 500,000 and one breach would lose 40% of it, so
SLE = 500,000 × 0.4 = 200,000. - A breach is expected about once every four years, so
ARO = 0.25andALE = 200,000 × 0.25 = 50,000per year. - A monitoring and encryption upgrade costs 15,000 per year and is expected to cut the rate to once in twenty years, so the new
ALE = 200,000 × 0.05 = 10,000. - The control reduces expected loss by
50,000 − 10,000 = 40,000a year, for a net benefit of40,000 − 15,000 = 25,000.
The control pays for itself even if the estimates are off by a wide margin.
Q7.What are the four ways to treat a risk?
Once a risk is assessed, an organization can avoid, mitigate, transfer or accept it. The choice depends on the risk's size, the cost of each option and the business value of the activity.
Avoid Mitigate Transfer Accept Stop the activity that creates the risk Add controls to lower likelihood or impact Share the financial impact with another party Knowingly live with the remaining risk Stop storing card numbers and use a payment provider's token Patch, encrypt, add multi-factor authentication Cyber insurance, contractual liability with a supplier A low-impact flaw in an internal tool scheduled for retirement Points interviewers look for:
- Acceptance must be formal: a named business owner signs it, with a reason and an expiry date, and it is reviewed again.
- Transfer moves money, not accountability. Insurance can pay for recovery, but customers still blame the company that lost their data.
- After mitigation some residual risk always remains, and that residual risk is what gets accepted.
- Security teams advise; the business owner of the asset makes the final risk decision.
Q8.What is zero trust, and how does it differ from perimeter-based security?
Zero trust is a security model in which no request is trusted because of where it comes from: every access is verified using identity, device health and context, and is granted only to the specific resource needed. Perimeter security, by contrast, trusts anything inside the corporate network.
Perimeter model Zero trust Trust based on network location Trust based on identity, device and context Access to the whole internal network Access to one application or resource at a time Checked once, at login or connection Checked on every request or session Lateral movement is easy once inside Lateral movement limited by per-service policy Remote access through a network-level tunnel back to the office Remote access direct to each app through an access proxy Core principles:
- Verify explicitly: strong authentication plus device posture and risk signals.
- Least privilege: short-lived, narrowly scoped access.
- Assume breach: segment everything and monitor as if an attacker is already inside.
Zero trust is a strategy that is adopted step by step, usually starting with strong identity and the most sensitive applications. No single product delivers it on its own.
Q9.What is an attack surface, and how do you reduce it?
The attack surface is the sum of all the points where an attacker could try to get in or pull data out: exposed services, applications, APIs, accounts, devices and people. Every one of those points needs defending, so a smaller surface is easier to protect.
Parts of the surface:
- Digital: open ports, web applications, APIs, cloud storage, remote access services and third-party integrations.
- Human: staff who can be phished or tricked over the phone.
- Physical: offices, laptops and removable media.
How to reduce it:
- Inventory first: discover every internet-facing asset, including forgotten test systems and old domains.
- Remove what is not needed: unused services, ports, features, accounts and dependencies.
- Hide what must exist: put admin interfaces and databases on private networks behind authentication.
- Harden defaults: disable sample content, default credentials and verbose error messages.
- Watch for change: scan the external surface continuously, because new exposure appears with every deployment.
Attack surface reduction is often the cheapest security win available. A service that is switched off cannot be exploited.
Q10.What is threat modeling, and how would you run a session for a new feature?
Threat modeling is a structured way to find what could go wrong in a design before it is built, and to decide what to do about it. It answers four questions: what are we building, what can go wrong, what will we do about it, and did we do a good job?
flowchart LR A["Draw the data flow"] --> B["Mark trust boundaries"] B --> C["List threats per element"] C --> D["Rate and prioritize"] D --> E["Choose mitigations"] E --> F["Track and verify"]A common checklist for the "what can go wrong" step is STRIDE:
Spoofing Tampering Repudiation Violates authenticity Violates integrity Violates non-repudiation Logging in as another user Changing a price in a request Denying an action because nothing was logged Information disclosure Denial of service Elevation of privilege Violates confidentiality Violates availability Violates authorization An error page leaking stack traces Flooding an expensive endpoint A normal user reaching admin functions Running the session: bring a developer, a product owner and a security engineer; keep it to about an hour; and turn each accepted threat into a tracked work item with an owner.
Example
A threat model for a "forgot password" feature, one threat per category that applies:
- Spoofing: an attacker guesses a reset token. Mitigation: 32 random bytes from a secure generator, single use, valid for 15 minutes.
- Information disclosure: different messages reveal which emails have accounts. Mitigation: the same response for every address.
- Denial of service: a script requests thousands of reset emails for one victim. Mitigation: rate limits per account and per source address.
- Tampering: the reset link carries the user ID, which an attacker edits. Mitigation: the server looks the user up from the token alone.
- Repudiation: a user claims they never changed their password. Mitigation: log every reset with time and source, and notify the account owner.
Five concrete work items came out of a one-hour session, before any code was written.
Q11.How do security policies, standards, procedures and guidelines differ?
They form a hierarchy from intent to instruction: a policy states what must be achieved, a standard sets specific mandatory requirements, a procedure gives the exact steps, and a guideline offers optional advice.
Policy Standard Procedure Guideline High-level intent approved by leadership Specific, measurable requirements Step-by-step instructions Recommended practice Mandatory Mandatory Mandatory for that task Optional Customer data must be encrypted in transit and at rest Use TLS 1.2 or later and disable older versions How to rotate the database encryption key Prefer managed key services for new projects Why keep them separate:
- Policies change rarely and need executive approval, while standards change as technology changes. Mixing them makes every technical update a leadership decision.
- Auditors test against policies and standards, so they must be specific enough to check.
- Procedures let anyone on call perform a sensitive task the same, safe way.
Every standard should trace back to a policy, and every exception should be documented, approved and given an expiry date.
Q12.How do you classify data, and why does classification drive security controls?
Data classification sorts information into a few levels by the harm its disclosure, alteration or loss would cause. Each level then comes with required controls, so people do not have to make security decisions file by file.
Public Internal Confidential Restricted Marketing pages, published prices Org charts, internal wikis Customer records, contracts Payment data, health records, secret keys Integrity checks only Staff-only access Encryption, need-to-know access, audit logs Strong encryption, strict access, monitoring, short retention How to make it work:
- Assign owners: each dataset has a business owner who decides its level.
- Label it: tags on files, storage buckets and database tables so tools can apply rules automatically.
- Tie controls to labels: encryption, access approvals, data loss prevention rules and retention follow the label.
- Review it: data changes over time, and a combined dataset can be more sensitive than its parts.
Keep the scheme to three to five levels. More than that and people pick at random, which defeats the purpose.
Q13.What is the difference between encoding, encryption and hashing?
Encoding changes data into another format so systems can handle it, encryption hides data so only key holders can read it, and hashing produces a fixed-size fingerprint that cannot be reversed. Only encryption and hashing are security tools, and they do different jobs.
Encoding Encryption Hashing For a safe transport or storage format For confidentiality For integrity, fingerprints and password storage Reversible by anyone Reversible with the key Not reversible Uses no key Uses a key Uses no key, unless it is a keyed hash Output grows with the input Output grows with the input Output has a fixed size Example: Base64, URL encoding Example: AES in an authenticated mode Example: SHA-256 Common mistakes:
- Treating Base64 as protection. Anyone can decode it in one step.
- Saying a hash can be "decrypted". It cannot be reversed; attackers guess inputs and compare hashes instead.
- Using a fast hash for passwords. Speed helps attackers guess billions of candidates per second, so passwords need a slow, salted algorithm.
Q14.How do symmetric and asymmetric encryption differ, and why are they usually combined?
Symmetric encryption uses one shared secret key to encrypt and decrypt, and it is fast. Asymmetric encryption uses a key pair, a public key that anyone can have and a private key that stays secret, and it solves key distribution but is much slower.
Symmetric Asymmetric One shared secret key A public and private key pair Fast, suits bulk data Slow, suits small values Hard key distribution: the secret must be shared safely Easy key distribution: the public key can be published Encrypts files, disks and traffic Used for key exchange and digital signatures Example algorithms: AES, ChaCha20 Example algorithms: elliptic-curve and integer-factoring schemes Why systems combine them (hybrid encryption):
- The two sides use asymmetric cryptography to agree on, or securely send, a fresh symmetric key.
- All the actual data is then encrypted with that symmetric key.
- The asymmetric keys also sign the exchange, so each side knows who it is talking to.
This gives the convenience of public keys with the speed of symmetric ciphers. Secure web connections, encrypted messaging and envelope encryption of stored data all work this way.
Q15.What properties make a cryptographic hash function secure?
A secure hash function maps any input to a fixed-size output in a way that cannot be reversed, cannot be forced to collide, and changes completely when the input changes slightly.
- Preimage resistance: given a hash, it is infeasible to find any input that produces it.
- Second-preimage resistance: given one input, it is infeasible to find a different input with the same hash.
- Collision resistance: it is infeasible to find any two inputs with the same hash.
- Avalanche effect: changing one bit of input changes about half the output bits.
- Deterministic and fixed-size: the same input always gives the same output of the same length.
Which algorithms are safe: MD5 and SHA-1 have practical collision attacks, so they must not be used for signatures or certificates. SHA-256, SHA-512 and SHA-3 are current choices.
Being fast is a feature for file integrity checks but a weakness for passwords. Password storage needs a deliberately slow function with a salt, not a general-purpose hash.
Q16.How should an application store user passwords?
Store passwords with a slow, salted, adaptive password-hashing function, never in plaintext and never with reversible encryption. The goal is that a stolen database gives attackers nothing they can use quickly.
- Pick a password-hashing algorithm: Argon2id, scrypt, bcrypt or PBKDF2 with a high iteration count. General hashes such as SHA-256 alone are too fast.
- Use a unique random salt per password, so identical passwords produce different hashes and precomputed tables are useless.
- Tune the work factor so one hash takes a noticeable fraction of a second on your servers, and raise it as hardware improves.
- Store the algorithm, parameters, salt and hash together, so old hashes can be upgraded when a user next logs in.
- Compare in constant time to avoid leaking information through response timing.
- Optionally add a pepper: a secret kept outside the database, such as in a key management service, so a database dump alone is not enough.
Pair storage with login protections: rate limiting, checks against known breached passwords and multi-factor authentication.
Example
Hashing and verifying passwords with salted PBKDF2 from the standard library:
import hashlib import hmac import secrets ITERATIONS = 600_000 def hash_password(password: str) -> str: salt = secrets.token_bytes(16) digest = hashlib.pbkdf2_hmac("sha256", password.encode(), salt, ITERATIONS) return f"pbkdf2_sha256${ITERATIONS}${salt.hex()}${digest.hex()}" def verify_password(password: str, stored: str) -> bool: _, iterations, salt_hex, digest_hex = stored.split("$") digest = hashlib.pbkdf2_hmac("sha256", password.encode(), bytes.fromhex(salt_hex), int(iterations)) return hmac.compare_digest(digest.hex(), digest_hex) stored = hash_password("river-lantern-42-quiet") print(stored.split("$")[:2]) # ['pbkdf2_sha256', '600000'] print(verify_password("river-lantern-42-quiet", stored)) # True print(verify_password("River-lantern-42-quiet", stored)) # False print(hash_password("same") == hash_password("same")) # FalseThe last line shows the salt at work: the same password never produces the same stored value twice.
Q17.What is a message authentication code, and how does it differ from a digital signature?
A message authentication code (MAC) is a short tag computed from a message and a shared secret key; anyone with the key can create or check it. A digital signature uses a private key to sign and a public key to verify, so anyone can check it but only the key owner can create it.
MAC, such as HMAC Digital signature One shared secret The private key signs, the public key verifies Only holders of the secret can verify Anyone with the public key can verify Anyone who can verify can also create one Only the private key owner can create one No non-repudiation Provides non-repudiation Very fast Slower Used for webhooks, API request signing, session cookies Used for software releases, certificates, signed documents When to use which:
- Use a MAC between two parties that already share a secret, such as your server and a payment provider's webhook.
- Use a signature when many parties must verify without being able to forge, such as users checking a software update.
- Both prove integrity and origin. Neither hides the content; add encryption for that.
Example
Verifying a webhook with HMAC-SHA256, the way a server checks that a callback really came from its partner:
import hashlib import hmac SECRET = b"shared-webhook-secret" def sign(body: bytes) -> str: return hmac.new(SECRET, body, hashlib.sha256).hexdigest() def verify(body: bytes, signature: str) -> bool: return hmac.compare_digest(sign(body), signature) body = b'{"order": 1042, "status": "paid"}' signature = sign(body) # sent by the partner in a request header print(len(signature)) # 64 print(verify(body, signature)) # True print(verify(b'{"order": 1042, "status": "refunded"}', signature)) # Falsecompare_digesttakes the same time whether the first or the last character differs, so an attacker cannot learn the correct tag byte by byte from response times.Q18.How do digital signatures provide integrity and non-repudiation?
A digital signature binds a message to the holder of a private key: the signer hashes the message and signs the hash with the private key, and anyone can check the result with the matching public key.
- Sign: the signer computes a hash of the message and creates a signature from that hash with the private key.
- Send: the message travels with its signature, and usually with a certificate that holds the public key.
- Verify: the receiver hashes the message it received and uses the public key to check the signature against that hash.
- Decide: a valid signature means the message is unchanged and was signed with that private key.
sequenceDiagram participant S as Signer participant R as Receiver S->>S: Hash message and sign with private key S->>R: Message plus signature R->>R: Hash received message R->>R: Verify signature with public key R-->>S: Accept only if the check passesWhat it does and does not give:
- Integrity: any change to the message makes verification fail.
- Non-repudiation: only the private key holder could have signed, provided the key was protected.
- No confidentiality: the message itself is readable unless it is also encrypted.
- Trust in the public key still has to come from somewhere, which is the job of certificates.
Q19.How does a certificate chain of trust work?
A certificate chain links a server's certificate to a root authority that the client already trusts. Each certificate is signed by the one above it, so verifying every signature up the chain proves the server's public key is genuine.
flowchart LR A["Root authority in the trust store"] -->|signs| B["Intermediate authority"] B -->|signs| C["Server certificate"] C -->|presented to| D["Client"] D -->|checks each signature up to| A- Root: a self-signed certificate shipped in the operating system or browser trust store, and kept offline by its owner.
- Intermediate: signed by the root and used for day-to-day issuing, so the root key is rarely exposed.
- Leaf: the server's own certificate, signed by the intermediate and naming the domain.
- Validation: the client checks signatures, validity dates, the hostname, permitted key usage and revocation status.
Common failures in practice:
- The server sends only its leaf certificate and omits the intermediate, so some clients cannot build the chain.
- The certificate expired because renewal was manual.
- The hostname does not match, such as a certificate for the bare domain served on a subdomain.
Interview tip: mention that the server must send the intermediate certificates; a missing intermediate is one of the most common real-world certificate errors.
Q20.Walk through a TLS 1.3 handshake.
A TLS 1.3 handshake agrees on keys and authenticates the server in one round trip. Both sides contribute an ephemeral key share, derive the same session keys, and the server proves it owns its certificate.
sequenceDiagram participant C as Client participant S as Server C->>S: ClientHello with cipher suites and key share S->>C: ServerHello with its key share S->>C: Certificate and CertificateVerify, encrypted S->>C: Finished C->>C: Validate certificate chain and hostname C->>S: Finished C->>S: Encrypted application data- ClientHello: the client lists supported cipher suites and sends an ephemeral key share.
- ServerHello: the server picks a suite and sends its own key share. Both sides now derive the handshake keys, so everything after this is encrypted.
- Authentication: the server sends its certificate and signs the handshake transcript with its private key.
- Finished messages: each side confirms the whole handshake was not altered.
What changed from older versions:
- Only ephemeral key exchange is allowed, so every session has forward secrecy.
- Weak ciphers and modes were removed; only authenticated encryption remains.
- An optional zero round-trip resumption sends data immediately, but that early data can be replayed, so it must be limited to safe, repeatable requests.