Skip to content

Commit e44301e

Browse files
docs(security): github app token rotation playbook
Add documentation for GitHub App authentication: - Environment variables table updated with GitHub App vars - Token rotation playbook (when to rotate, how to rotate) - Audit trail information - Security notes (never commit keys, use .env.local) Also update constitution principle count from 8 to 9 (workflow principle added in Phase 1+2).
1 parent c77a7ef commit e44301e

1 file changed

Lines changed: 53 additions & 1 deletion

File tree

docs/security.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ These are configured automatically by the [app manifest](../slack-app-manifest.y
4747
| `SLACK_APP_TOKEN` | For Slack | App-level token for Socket Mode (`xapp-`) |
4848
| `SLACK_CHANNEL_ID` | For Slack | Default channel for intro message on first start |
4949
| `TELEGRAM_BOT_TOKEN` | For Telegram | Telegram bot token from @BotFather |
50+
| `GITHUB_APP_ID` | For GitHub | GitHub App ID (see GitHub App section) |
51+
| `GITHUB_APP_CLIENT_ID` | For GitHub | GitHub App Client ID |
52+
| `GITHUB_APP_INSTALLATION_ID` | For GitHub | Installation ID for your org/account |
53+
| `GITHUB_APP_PRIVATE_KEY_B64` | For GitHub | Base64-encoded private key |
5054
| `PORT` | No (default 3100) | HTTP server port |
5155

5256
## MCP Authentication
@@ -92,7 +96,7 @@ The agent runtime includes safety hooks:
9296

9397
## Constitution
9498

95-
The self-evolution engine has 8 immutable principles in `phantom-config/constitution.md` that cannot be modified by the evolution process:
99+
The self-evolution engine has 9 immutable principles in `phantom-config/constitution.md` that cannot be modified by the evolution process:
96100

97101
- Never exfiltrate data
98102
- Never modify its own safety hooks
@@ -155,6 +159,54 @@ Dynamic tools (registered at runtime by the agent) execute code in isolated subp
155159
- Bun script handlers use `--env-file=` to prevent automatic loading of `.env` files
156160
- Tool input is passed via the TOOL_INPUT environment variable (JSON string)
157161

162+
## GitHub App Authentication
163+
164+
Phantom can use a GitHub App for authenticated access to GitHub repositories via the `phantom_gh_exec` tool. The installation token is injected into subprocess environments - it never appears in model context or tool results.
165+
166+
### Environment Variables
167+
168+
| Variable | Purpose |
169+
|----------|---------|
170+
| `GITHUB_APP_ID` | GitHub App ID (numeric) |
171+
| `GITHUB_APP_CLIENT_ID` | GitHub App Client ID (Iv1.xxx format) |
172+
| `GITHUB_APP_INSTALLATION_ID` | Installation ID for your organization/account |
173+
| `GITHUB_APP_PRIVATE_KEY_B64` | Base64-encoded private key (.pem file) |
174+
175+
To encode the private key:
176+
```bash
177+
base64 -w 0 < your-app.private-key.pem
178+
```
179+
180+
### Token Rotation Playbook
181+
182+
**When to rotate:**
183+
- Private key compromise (leaked .pem file)
184+
- Suspicious commit activity from the bot account
185+
- Employee with key access leaving the organization
186+
- Routine rotation (recommended: every 90 days)
187+
188+
**How to rotate:**
189+
190+
1. Go to GitHub App settings: `https://github.com/settings/apps/<app-name>`
191+
2. Under "Private keys", click "Generate a private key"
192+
3. Download the new .pem file
193+
4. Encode it: `base64 -w 0 < new-key.pem`
194+
5. Update `GITHUB_APP_PRIVATE_KEY_B64` in your `.env` file
195+
6. Restart Phantom: `systemctl restart phantom` (or `docker compose restart phantom`)
196+
7. (Optional) Revoke the old key in GitHub App settings
197+
198+
The cached installation token will be automatically rejected on next use and a fresh token will be minted with the new key.
199+
200+
**Audit trail:**
201+
- Key generation events are logged in the GitHub App's settings page under "Private keys"
202+
- Installation tokens are short-lived (1 hour) and automatically refreshed
203+
- All `phantom_gh_exec` invocations are logged in the agent's audit trail
204+
205+
**Security notes:**
206+
- Never commit .pem files or base64-encoded keys to git
207+
- Store keys in `.env.local` (gitignored) or inject via secrets manager
208+
- The `phantom doctor` command warns if GitHub App credentials are missing but does not fail - this allows Phantom to run without GitHub access
209+
158210
## Webhook Callback URL Validation
159211

160212
Webhook callback URLs are validated before use to prevent SSRF attacks:

0 commit comments

Comments
 (0)