1.5 KiB
1.5 KiB
LFCA 4.2: Sensitive data
A secret committed to Git and taken out of its history again, and a file encrypted before its original is shredded.
Before you start
Work as root (sudo -i). The lab installs Git if it's missing and creates
a test repository, /root/leaky, in which someone committed a file
config.env with a fake API key, and later commits on top. It also
creates /root/customers.csv. It notes which packages were installed, and
reset puts that back. The VM needs internet access to install the tools.
Tasks
- Find the key in
/root/leakywithgitleaks detect(from Ubuntu's packages; on the RHEL family, the upstream release) or withgit log -p | grep. Then removeconfig.envfrom the whole history withgit filter-repo --force --path config.env --invert-paths, keeping the other files and commits. Note why the key would still need to be rotated. - Encrypt
/root/customers.csvwithgpg -c, and delete the original withshred -u. Then readman shredand note why it isn't reliable on SSDs or on copy-on-write filesystems such as Btrfs.
Hints
cd /root/leaky,git log --oneline --stat,git log -p | grep -i key.apt install gitleaks git-filter-repoon Ubuntu. On the RHEL family,git-filter-repois in EPEL (dnf install epel-release, thendnf install git-filter-repo).- After filter-repo,
git log --all --oneline -- config.envshows nothing. gpg -c customers.csvasks for the passphrase twice;lsaftershred -u.