Flag Snapshots With Ransomware-Like Entropy Spikes in Pandas

Last updated: November 29, 2026

Quick Overview

From per-snapshot file change records with before and after entropy, flag snapshots where far more files than usual turned from low to high entropy compared with that object's recent history.

Rubrik
Data Manipulation (SQL/Python)
Data Scientist
Rubrik
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


From per-snapshot file change records with before and after entropy, flag snapshots where far more files than usual turned from low to high entropy compared with that object's recent history.

Rubrik's anomaly detection looks at file-system changes between backups to spot encryption by ransomware. This question checks pandas grouping, per-object baselines that exclude the current row, and thresholds that avoid noise on quiet servers.

What the Interviewer Expects
  • Filter to modifications and define the encrypted-like signal
  • Fill snapshots with no changes as 0, not drop them
  • Compute a trailing baseline per object that excludes the current snapshot
  • Combine relative and absolute thresholds
  • Sanity-check on a synthetic attack
Key Topics to Cover
pandas groupby
rolling windows
anomaly detection
entropy
baselines
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • Files that were already compressed (zip, jpg) look encrypted. How do you control for them?
  • How would you write the same logic in SQL with window functions?
  • How would you pick the ratio and minimum thresholds from labeled incidents?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

changes: one row per changed file per snapshot, with change_type and Shannon entropy before and after in bits per byte. snapshots: one row per snapshot with object_id and taken_at. Encryptio...

Approach

Count per snapshot the modified files that crossed from below 6.0 to above 7.5. Left-join onto all snapshots so quiet snapshots get 0. Per object, take the median of the previous k counts (shift by 1 ...


Submit Your Answer
Markdown supported

Related Questions