Agent Wranglers

TKO-40Required

Remove the previous team's access inside the product

List every way into the running product that is not a vendor account, and remove each one that no current person or service owns. That covers admin users, SSH keys, deploy keys, API tokens, OAuth apps and webhooks.

How to do it

Take control of every account before touching the code secures the vendor accounts, and Rotate every secret the previous team could read replaces shared secrets. A former developer may still hold an admin user in the app, a key in authorized_keys or a personal API token. A webhook or an OAuth app can keep sending data to an address the old team controls. Query the users table for admin roles, and read authorized_keys for every user on every server. List the deploy keys, installed apps and webhooks in the code host and in each vendor. Remove what has no current owner, and record the rest with its owner in the system map.

Examples

Shell example

# Every key that can sign in to each server, with its comment
for host in app1.example.com app2.example.com; do
  ssh "$host" 'sudo sh -c "cat /root/.ssh/authorized_keys /home/*/.ssh/authorized_keys 2>/dev/null"' | awk -v h="$host" '{ print h, $NF }'
done
# Deploy keys and webhooks on the repository
gh api repos/example/shop/keys --jq '.[] | [.id, .title, .created_at] | @tsv'
gh api repos/example/shop/hooks --jq '.[] | [.id, .config.url] | @tsv'

SQL example

-- Admin users in the app, oldest sign-in first
SELECT email, role, last_sign_in_at FROM users WHERE role IN ('admin', 'owner') ORDER BY last_sign_in_at;

How to check

The access list names every admin user, SSH key, deploy key, API token, OAuth app and webhook, each with a current owner. A fresh query of admin users and a scan of every authorized_keys file find no entry missing from the list.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/codebase-takeover/triage/remove-inherited-access">Agent Wranglers codebase takeover playbook</a>. In code you write, add a comment next to it with the same link.