Security_Interview_Questions

Cryptography

Asymmetric vs symmetric

Asymmetric is slow, but good for establishing a trusted connection.

Symmetric has a shared key and is faster. Protocols often use asymmetric to transfer symmetric key.

Perfect forward secrecy - eg Signal uses this.

Encryption standards + implementations

Symmetrical

Asymmetrical

SSL & TLS

Different between SSL \ TLS \ HTTPS

SSL: standard technology for keeping an internet connection secure and safeguarding any sensitive data that is being sent between two systems, preventing criminals from reading and modifying any information transferred, including potential personal details.

TLS: cryptographic protocol that provides secure communication over the Internet. TLS protocol aims primarily to provide privacy and data integrity between two communicating computer applications.

HTTPS: secure version of HTTP, the protocol over which data is sent between your browser and the website that you are connected to. TLS and SSL are most widely recognized as the protocols that provide secure HTTP (HTTPS) for Internet transactions between Web browsers and Web servers.

HTTPS uses TCP at the transport layer. SSL is used for data encryption.

Does TLS use symmetric or asymmetric encryption?

Both, initial exchange is done using asymmetric and that bulk data encryption requires speed and therefore symmetric algorithms.

What is HTTP Strict Transport Security (HSTS)?

HSTS is a header which allows a website to specify and enforce security policy in client web browsers. This policy enforcement protects secure websites from downgrade attacks, SSL stripping, and cookie hijacking. It allows a web server to declare a policy that browsers will only connect using secure HTTPS connections, and ensures end users do not “click through” critical security warnings. HSTS is an important security mechanism for high security websites. HSTS headers are only respected when served over HTTPS connections, not HTTP.

HSTS generally has the following behavior in user web browsers:

More details: Cloudflare Understanding HSTS (HTTP Strict Transport Security)

If someone steals the server’s private key can they decrypt all previous content sent to that server?

It depends on the key exchange. With static RSA key exchange (no forward secrecy), yes — anyone who recorded past traffic can use the stolen private key to recover each session key and decrypt it retroactively. With ephemeral Diffie-Hellman (DHE/ECDHE, i.e. Perfect Forward Secrecy), no — the session keys are ephemeral and never transmitted, so a stolen long-term key cannot decrypt previously captured sessions (though it does let the attacker impersonate the server or run an active MITM going forward).

What are some common ways that TLS is attacked, and/or what are some ways it’s been attacked in the past?

weak ciphers, vulnerabilities like Heartbleed, BEAST,

What is Forward Secrecy?

a system that uses ephemeral session keys to do the actual encryption of TLS data so that even if the server’s private key were to be compromised, an attacker could not use it to decrypt captured data that had been sent to that server in the past.

Public Key Infrastructure

Cryptographically speaking, what is the main method of building a shared secret over a public medium?

Diffie-Hellman

What’s the difference between Diffie-Hellman and RSA?

Diffie-Hellman is a key-exchange protocol, and RSA is an encryption/signing protocol. RSA required key material beforehand, DH does not

What kind of attack is a standard Diffie-Hellman exchange vulnerable to?

MITM

What’s the difference between encoding, encryption, hashing, Obfuscation, and Signing?

Various attack models (e.g. chosen-plaintext attack).

What is an IV used for in encryption?

An Initialization Vector is a non-secret but random/unique value fed into a cipher so that encrypting the same plaintext under the same key produces different ciphertext each time, preventing patterns from leaking. In CBC it is XORed with the first plaintext block and must be unpredictable; in CTR/GCM it forms the nonce/counter and must never be reused for a given key (nonce reuse in GCM is catastrophic and can leak the authentication key). The IV is normally sent in the clear alongside the ciphertext.

Cipher Modes

What are block and stream ciphers? What are the differences, and when would you use one vs. the other?

Block-based encryption algorithms work on a block of cleartext at a time, and are best used for situations where you know how large the message will be, e.g., for a file. Stream ciphers work on single units of cleartext, such as a bit or a byte, and they’re best used when you’re not sure how long the message will be.

What are some common block cipher modes?

ECB (Electronic Code Book) and CBC (Cipher Block Chaining).

What’s the main difference in security between ECB and CBC?

ECB (Electronic Code Book) encrypts each block independently, without using an IV, so identical plaintext blocks always produce identical ciphertext blocks. This leaks patterns in the data (the classic “ECB penguin” image) and makes it fairly easy to attack.

CBC (Cipher Block Chaining) uses an IV for the first block and then propagates the XOR of the previous block onto subsequent ones. The difference in results can be remarkable.

Integrity and authenticity primitives

Entropy

What are the different ways in which the authentication of a person can be performed

  1. Passwords: Something user know
  2. Token: Something user have
  3. Biometrics: Someone user is
  4. OTP: one time password

Security Modules

What is HSM Hardware Security Module?

A security device you can add to a system to manage, generate, and securely store cryptographic keys.

What is TPM Trusted Platform Modules?

A hardware chip on the computer’s motherboard that stores cryptographic keys used for encryption. Many laptop computers include a TPM, but if the system doesn’t include it, it is not feasible to add one.

Trusted storage for certs and auth data locally on device/host.

HSM vs TPM

HSMs are removable or external devices. In comparison, a TPM is a chip embedded into the motherboard. You can easily add an HSM to a system or a network, but if a system didn’t ship with a TPM, it’s not feasible to add one later. Both provide secure encryption capabilities by storing and using RSA keys.