9 Security Engineer interview questions with complete model answers, spanning Technical, Coding, System design, Behavioral. The bank holds 9 Security Engineer questions in total, tagged by round and difficulty.
9 Security Engineer questions in the bank
4 categories: Technical, Coding, System design, Behavioral
Asked at Cisco, Canonical and more
BehavioralMediumSecurity EngineerHiring manager
1. How can I trust you if you are switching jobs after a very short time?
Model answer
Situation — I understand why a short tenure raises a concern: you need someone who will stay long enough to build context, earn trust, and deliver security outcomes. In my case, the timing of my search reflects a considered decision about role fit and long-term direction, not a casual approach to changing jobs.
Task — My responsibility is to be candid about the move and show that I have done the work to assess whether this opportunity is a durable fit. I also want to make clear that I take commitments to my current team seriously.
Action
I would explain the specific reason for exploring a change plainly, without blaming my manager or sharing confidential details. For example, if the role’s scope or priorities changed after I joined, I would describe what changed and how I tried to address it first.
I would share what I delivered during my time there, with concrete examples—such as a risk I helped reduce, a security process I improved, or a cross-functional effort I drove. I would use outcomes I can substantiate rather than imply that tenure alone proves impact.
Before pursuing Cisco, I would evaluate the actual work: the security problems the team owns, how it partners with engineering and product, and what success looks like over the first year. I would ask direct questions rather than assume the role matches its description.
I would connect that evaluation to my longer-term goals: working on security at scale, collaborating across a complex technology environment, and building protections that work for customers as well as internal teams.
If we agreed there was a fit, I would make a responsible transition—documenting work, handing off open risks, and respecting my current employer’s obligations.
Result — I can’t ask you to trust me based only on a promise; I’d want to earn that trust through transparent answers, relevant evidence, and consistent follow-through. I’m being selective because I want my next move to be a place where I can commit, grow, and make sustained contributions. I’d be glad to discuss any part of my timeline or decision in more detail.
CodingEasySecurity EngineerTechnical round
2. How would you sort an array containing 0s, 1s, and 2s?
Model answer
function sort012(nums) {
// [0, low) contains 0s, [low, mid) contains 1s,
// and (high, end] contains 2s.
let low = 0;
let mid = 0;
let high = nums.length - 1;
while (mid <= high) {
if (nums[mid] === 0) {
[nums[low], nums[mid]] = [nums[mid], nums[low]];
low++;
mid++;
} else if (nums[mid] === 1) {
mid++;
} else if (nums[mid] === 2) {
[nums[mid], nums[high]] = [nums[high], nums[mid]];
high--;
// Do not advance mid: the swapped-in value is not classified yet.
} else {
throw new RangeError(`Expected only 0, 1, or 2; got ${nums[mid]}`);
}
}
return nums;
}
console.log(sort012([2, 0, 2, 1, 1, 0])); // [0, 0, 1, 1, 2, 2]
Use the Dutch National Flag algorithm with three pointers; it sorts in place without comparison sorting.
When a 2 is swapped from the right, recheck the current position because the incoming value is unclassified.
Complexity: O(n) time, O(1) extra space.
CodingMediumSecurity EngineerTech Round 2
3. How would you count the number of islands in a grid using BFS, considering all eight neighboring directions?
Model answer
function countIslands(grid) {
if (grid.length === 0 || grid[0].length === 0) return 0;
const rows = grid.length;
const cols = grid[0].length;
const directions = [
[-1, -1], [-1, 0], [-1, 1],
[0, -1], [0, 1],
[1, -1], [1, 0], [1, 1]
];
const visited = Array.from({ length: rows }, () => Array(cols).fill(false));
let islands = 0;
for (let r = 0; r < rows; r++) {
for (let c = 0; c < cols; c++) {
if (grid[r][c] !== "1" || visited[r][c]) continue;
islands++;
visited[r][c] = true;
const queue = [[r, c]];
// Mark cells when enqueuing so each land cell enters the queue once.
for (let head = 0; head < queue.length; head++) {
const [row, col] = queue[head];
for (const [dr, dc] of directions) {
const nr = row + dr;
const nc = col + dc;
if (
nr >= 0 && nr < rows && nc >= 0 && nc < cols &&
grid[nr][nc] === "1" && !visited[nr][nc]
) {
visited[nr][nc] = true;
queue.push([nr, nc]);
}
}
}
}
}
return islands;
}
const grid = [
["1", "0", "0"],
["0", "1", "0"],
["0", "0", "1"]
];
console.log(countIslands(grid)); // 1: diagonal land is connected
Scan each cell; when unvisited land is found, increment the count and BFS through all eight neighbors.
This treats diagonal contact as connected and leaves the input grid unchanged by using a separate visited matrix.
Complexity: Time O(rows × cols); space O(rows × cols) for visited cells and the queue.
CodingMediumSecurity EngineerTech Round 1
4. How would you solve the Majority Element II problem?
Model answer
function majorityElementII(nums) {
// At most two values can occur more than floor(n / 3) times.
let candidate1 = null;
let candidate2 = null;
let count1 = 0;
let count2 = 0;
// Find up to two candidates using the extended Boyer-Moore algorithm.
for (const value of nums) {
if (candidate1 === value) {
count1++;
} else if (candidate2 === value) {
count2++;
} else if (count1 === 0) {
candidate1 = value;
count1 = 1;
} else if (count2 === 0) {
candidate2 = value;
count2 = 1;
} else {
count1--;
count2--;
}
}
// Candidates are not guaranteed to meet the threshold; verify them.
count1 = 0;
count2 = 0;
for (const value of nums) {
if (value === candidate1) count1++;
else if (value === candidate2) count2++;
}
const threshold = Math.floor(nums.length / 3);
const result = [];
if (count1 > threshold) result.push(candidate1);
if (count2 > threshold) result.push(candidate2);
return result;
}
console.log(majorityElementII([3, 2, 3])); // [3]
The cancellation pass keeps at most two possible values: more than two values cannot each occur over n / 3 times.
A second pass counts candidates and applies the strict > floor(n / 3) threshold.
Complexity: Time O(n); extra space O(1).
CodingMediumSecurity EngineerTech Round 1
5. How would you find the longest substring without repeating characters?
Model answer
function lengthOfLongestSubstring(s) {
// Track the most recent index for each character.
const lastSeen = new Map();
let left = 0;
let best = 0;
for (let right = 0; right < s.length; right++) {
const char = s[right];
// Move the window past a duplicate only if it is inside the window.
if (lastSeen.has(char) && lastSeen.get(char) >= left) {
left = lastSeen.get(char) + 1;
}
lastSeen.set(char, right);
best = Math.max(best, right - left + 1);
}
return best;
}
console.log(lengthOfLongestSubstring("abcabcbb")); // 3
Maintain a sliding window [left, right] with no repeated characters.
When a duplicate appears, advance left past its previous occurrence; never move it backward.
Complexity: Time O(n); space O(min(n, character set size)).
System designMediumSecurity EngineerTech Round 2
6. How would you design a data structure that supports insert, delete, getRandom, and getValue operations?
Model answer
1. Requirements & scale
I’ll assume the structure stores unique key → value entries: insert(key, value), delete(key), getValue(key), and getRandom() returning a uniformly random active entry. If the requirement instead means random values with duplicates, the indexing must track each duplicate separately.
Functional: support the four operations and define behavior for duplicate keys, missing keys, and empty random selection.
Non-functional: expected O(1) operations, uniform randomness, and thread safety if shared across concurrent callers.
Scale: For 1 million entries at roughly 64 bytes of array/reference and hash-table overhead per entry, plan for about 64–128 MB, depending on runtime and map implementation. Each operation is local memory work; there is no network bandwidth requirement.
2. High-level architecture
For a single process, the core is an array plus a hash map. In a distributed service, route each key to an owning shard; a random selection must sample from that shard’s active entries or use an additional global sampling layer.
flowchart TD
subgraph Client
C[Caller]
end
subgraph Edge
E[Gateway]
end
subgraph Load_Balancer
L[Load Balancer]
end
subgraph API_Services
A[Entry Service]
D[Array And Map]
end
subgraph Cache
K[Local Cache]
end
subgraph Datastores
S[Durable Store]
end
subgraph Message_Queue
Q[Change Events]
end
subgraph Workers
W[Persistence Worker]
end
C -->|operation request| E
E -->|authenticated request| L
L -->|route| A
A -->|read or mutate| D
D -->|lookup result| A
A -->|optional read through| K
A -->|durable snapshot or log| S
A -->|asynchronous mutation event| Q
Q -->|persist event| W
W -->|write| S
Diagram
3. API design
POST /entries — insert or replace a key and value; return whether it was newly inserted.
DELETE /entries/{key} — delete a key; return not-found if absent.
GET /entries/{key} — return the value or not-found.
GET /entries/random — return a random active key-value pair; return empty or 404 when no entries exist.
4. Data model & storage
The in-memory structure has items: Array<Entry> and index: Map<Key, Integer>. Each array slot contains {key, value}; the map points from key to its current array index. The array enables uniform random sampling, while the map enables direct lookup and deletion. For persistence, store entries in a SQL table keyed by key, or in a key-value store if simple key access is the primary need. The in-memory structure is a rebuildable index, not the durable source of truth.
5. Deep dive
Insert: if the key exists, update its value without changing the array. Otherwise, append the entry and record its array index in the map.
Get value: find the index in the map and read the corresponding array slot.
Get random: choose i = randomInt(0, items.length - 1) and return items[i]. Because every active entry occupies exactly one slot, this is uniform.
Delete: find the target index, move the last array entry into that slot, update the moved key’s map index, then pop the array and remove the deleted key. This avoids shifting elements.
Empty case: return a defined empty result rather than calling the random-number generator with an invalid range.
sequenceDiagram
participant Caller
participant Service
participant Map
participant Array
Caller->>Service: delete key
Service->>Map: find index
Map-->>Service: index and last index
Service->>Array: move last entry into index
Service->>Map: update moved key index
Service->>Array: remove last slot
Service->>Map: remove deleted key
Service-->>Caller: success
Diagram
All four operations are expected O(1) time; space is O(n). A lock around each operation makes compound array/map mutations atomic. In a security-sensitive service, authenticate callers, authorize access to the relevant namespace, validate key sizes, and avoid exposing predictable identifiers as authorization tokens.
6. Scale, bottlenecks & trade-offs
A single in-memory instance provides the simplest and fastest implementation but loses state on process failure unless it reloads from durable storage or a log. Replicas need a clear consistency model: independent local random reads are easy, but writes must be replicated or routed to a shard leader. A global getRandom across shards is not automatically uniform if shard sizes differ; choose a shard with probability proportional to its active count, then choose uniformly within that shard. That requires accurate counts or a sampling index. For a modest collection, favor the simple local structure and rebuild it from durable data; add sharding and distributed sampling only when memory or throughput requires them.
System designHardSecurity EngineerTechnical round
7. How would you design an API rate limiter using a low-level design approach?
Model answer
1. Requirements & scale
I’d design a low-level rate-limiting component that answers whether a request is allowed, enforces configurable policies, and remains safe when many API instances handle traffic concurrently. I’ll assume limits can be applied by tenant, user, API key, or IP, with a tenant policy taking precedence over a default.
Functional: configure limits, check requests, return allow/deny plus retry information, and support policy changes.
Non-functional: low latency, bounded memory, atomic decisions across instances, and graceful behavior during dependency failures.
Scale estimate: At 100,000 requests/second and one Redis operation per decision, the limiter must sustain 100,000 atomic checks/second, typically partitioned across Redis shards. At 100 bytes per active bucket and a 60-second idle TTL, 6 million active keys require roughly 600 MB raw, before Redis overhead and replication. A local cache can reduce policy reads but not safely replace shared counters for strict global limits.
2. High-level architecture
Use a client library or API gateway middleware for request classification, a policy service for configuration, and a shared low-latency store for atomic enforcement. A Redis Lua script performs the state transition as one operation. Policy changes flow asynchronously to invalidate local policy caches.
flowchart TD
subgraph Client
C[API Client]
end
subgraph Edge
E[Gateway Middleware]
end
subgraph Load_Balancer
L[Load Balancer]
end
subgraph API_Services
A[Rate Limit Service]
P[Policy Service]
end
subgraph Cache
K[Policy Cache]
R[Redis Cluster]
end
subgraph Datastores
S[Policy Database]
end
subgraph Message_Queue
Q[Policy Events]
end
subgraph Workers
W[Cache Invalidation Worker]
end
C -->|request| E
E -->|identity and route| L
L -->|check request| A
A -->|read policy| K
K -->|cache miss| P
P -->|load policy| S
A -->|atomic bucket update| R
A -->|allow or deny| E
P -->|publish change| Q
Q -->|invalidate policy| W
W -->|refresh cache| K
PUT /v1/policies/{policyId} — create or update algorithm, limit, window, scope, and action.
GET /v1/policies/{policyId} — inspect the active configuration.
DELETE /v1/policies/{policyId} — remove a policy and fall back to the parent/default policy.
The check endpoint should be internal to the gateway/service network and authenticated; do not trust a client-supplied subject without verifying its identity.
4. Data model & storage
Store policy definitions in SQL because updates need validation, audit history, and transactional ownership. A policy row includes policy_id, scope, algorithm, capacity, refill_rate, window_ms, cost_mode, enabled, and version.
Redis stores ephemeral state. Use a key such as rl:{tenantId}:{subjectId}:{routeId}; the hash tag keeps related keys on one Redis Cluster slot if multi-key scripts are needed. A token-bucket value can store tokens and last-refill time. Apply a TTL longer than the refill horizon so inactive buckets expire. Add a policy version to cache keys or state so policy changes cannot silently reuse incompatible counters.
5. Deep dive
For a general API, I’d start with a token bucket: capacity B, refill rate r tokens/second, and request cost c. At time t, calculate tokens = min(B, oldTokens + (t - oldTime) * r). Allow if tokens >= c, then subtract c; otherwise deny. The bucket permits bursts up to B while enforcing the long-run rate r.
The read, refill, decision, and write must be atomic. A Lua script in Redis avoids races between gateway instances. Use Redis server time inside the script, validate non-negative cost, and return the remaining tokens and next eligible time. retryAfterMs is approximately (c - tokens) / r * 1000. For a fixed-window policy, an atomic increment plus expiry is simpler but permits boundary bursts; a sliding-window log is more accurate but costs more memory and commands. A sliding-window counter is a practical middle ground.
Return HTTP 429 for a denied request, with Retry-After where meaningful. Exempt health checks and carefully chosen internal traffic to avoid cascading outages, while keeping exemptions explicit and audited.
6. Scale, bottlenecks & trade-offs
Shard Redis by the full bucket key and use replicas for recovery, while recognizing that replica reads can be stale and should not decide strict limits. If Redis is unavailable, choose policy by endpoint risk: fail closed for costly or security-sensitive actions; optionally fail open with a small local emergency limit for low-risk reads. Local fallback improves availability but allows aggregate overshoot proportional to the number of instances.
Use bounded policy caches with event-driven invalidation and a short TTL as a safety net. Protect against cardinality attacks by validating identity inputs, limiting key length, and setting bucket TTLs. A single global tenant bucket can become a hot key; split only if the product accepts an explicitly larger aggregate limit or approximate enforcement. Token buckets trade exact sliding-window accounting for low memory and smooth behavior. Keep policy updates strongly validated and auditable, but allow enforcement state to be eventually cleaned up. Monitor allow/deny rates, Redis latency and errors, hot keys, policy-cache misses, and decision latency; alert on both false-denial risk and uncontrolled traffic.
8. Which of these are not Python logging levels: URGENT, CRITICAL, INFO, FATAL, TRACE, …?
Model answer
Python’s standard logging levels are DEBUG, INFO, WARNING, ERROR, and CRITICAL.
URGENT is not a standard level name.
TRACE is not a standard level name, although applications can define it as a custom level.
FATAL is an alias for CRITICAL in Python’s logging module, so it is recognized, but it is not a distinct severity level.
Similarly, WARN is an alias for WARNING. Custom levels can be added with logging.addLevelName(), so the distinction is between Python’s built-in levels and names an application or library chooses to define.
TechnicalHardSecurity EngineerHiring manager
9. How would you process a real-time data stream containing predefined data types such as logs, metrics, and metadata, and extract information from it?
Model answer
Define a typed event envelope. Each event should carry a type (log, metric, or metadata), schema version, event ID, event time, source/device ID, tenant, and payload. I would use a format such as Protobuf or Avro for a high-volume stream, with a schema registry to validate compatibility and support evolution.
Ingest and validate. Producers publish to a durable broker such as Kafka. At the edge, authenticate producers, enforce tenant quotas, validate the envelope and payload against the declared schema, and reject or quarantine malformed or unknown types. Avoid trusting a type name alone; validate payload fields and apply size limits.
Route by type. A stream processor dispatches events to type-specific handlers. Log handlers parse fields and redact sensitive values; metric handlers validate units and aggregate time windows; metadata handlers update device or topology state. Include event time, not just arrival time, so late or reordered data can be handled correctly.
Extract and deliver information. Emit normalized records to suitable destinations: searchable storage for logs, a time-series store for metrics, and a durable state store for metadata. Produce derived alerts or summaries to a separate topic so downstream consumers do not block ingestion.
Make processing resilient and secure. Partition by a stable key such as tenant plus device ID when per-device ordering matters. Use checkpoints and idempotent writes keyed by event ID to handle retries; send poison events to a dead-letter topic with a reason. Monitor consumer lag, validation failures, processing latency, and dropped or late events. Encrypt data in transit and at rest, restrict topic access, and apply retention and privacy controls.
flowchart TD
P[Producers] -->|typed events| B[Durable broker]
B -->|event batches| V[Validate and authenticate]
V -->|valid events| R[Route by type]
V -->|invalid events| D[Dead-letter topic]
R -->|logs| L[Log parser and redactor]
R -->|metrics| M[Metric aggregator]
R -->|metadata| T[Metadata updater]
L -->|normalized logs| LS[Searchable log store]
M -->|time-series data| MS[Metrics store]
T -->|device state| TS[Metadata store]
L --> A[Alerts and derived events]
M --> A
T --> A
Diagram
This separates ingestion from downstream storage and analysis, so a slow log indexer does not stop metric processing. I would choose delivery semantics deliberately: at-least-once delivery with idempotent consumers is usually a practical default; exactly-once behavior requires end-to-end support and can add cost and latency.
Practice these out loud, don't memorise them
Reading an answer is not the same as being able to give one under pressure. ChannelPulse plays the interviewer, asks the follow-ups, and scores each answer with feedback and a model answer so you can hear the gap between what you said and what lands.