>_ IzzyLab

Hands-on task

This task is step 17 of the course “Investigating a server”

Evidence from an erased commit

hard~10 min

The server configs live in the git repository /srv/config-repo. The attacker committed the job cron/sync.sh there (commit update sync job) and then covered their tracks: git reset --hard rolled back the main branch, and they made a harmless commit on top. Now the file isn't in the working tree, and the commit isn't in git log either.

Recover the evidence without touching main: create a branch evidence that points to the erased commit — it must contain cron/sync.sh. The history of main must stay as it is (three commits).

What you'll practise:
  • git reflog
  • recovering commits
  • git branch
  • dangling commit
  • investigation

Topic breakdown

When no branch points to a commit any more (after reset --hard, rebase, or deleting a branch), the object itself doesn't disappear: it becomes "dangling" and stays in the database until git gc collects it (weeks, by default). Git records every movement of HEAD in the reference log, read with git reflog: it shows both the reset and the commit that came before it. In an investigation it's important not to rewrite the current history but to keep the finding separately — hang a new branch on the hash you found. Then the evidence won't be lost to garbage collection, and the working branch stays untouched.

What's checked

  1. branch evidence created
  2. evidence contains the erased cron/sync.sh
  3. main untouched

What it looks like