Auto-detect and remediate secret leaks from GitHub repos with n8n
GitHub push events → regex secret scan → AI classification → auto-revoke AWS keys / create Jira tickets / Slack alerts
- Who
- DevOps and security teams with an n8n instance, GitHub repos, and credentials for AWS, Jira, and Slack
- You get
- Automatically scan commits for high-impact secret leaks and respond by disabling AWS keys, creating Jira tasks, and sending Slack alerts
- You need
- n8n · slack · data-table
Constraints
Prerequisites: n8n instance with AI nodes enabled; GitHub OAuth2 credentials; OpenRouter API key; AWS IAM credentials with UpdateAccessKey permission; Jira Software Cloud API token; Slack API token; an n8n DataTable named processed_secrets must exist. Import the template, configure credentials per node, and set the GitHub webhook to the n8n trigger URL.
What they did
Author taiwo published a 26-node security automation workflow on the n8n template platform. The workflow listens for GitHub push events via webhook, extracts changed files with a Code node and fetches raw contents via HTTP Request, scans for AWS keys, payment processor keys, and database connection strings using RegEx, deduplicates via hashing, classifies leaks using a Claude model, and executes responses through a Switch node: AWS key revocation, Jira ticket creation, and Slack alerts.
How it went
The author reports the workflow reduces the exploitation window from hours to seconds, enabling immediate AWS key deactivation and traceable automated incident response (author_report).
Worth knowing
1) This site has not tested the workflow; reproduction=not_tested. 2) The DataTable node depends on an n8n internal processed_secrets table that must be created beforehand. 3) AWS credentials need IAM UpdateAccessKey permission; verify key ownership before deactivation to avoid disabling production keys. 4) Payment processor keys and database passwords only trigger alerts and tickets; they are not automatically revoked or rotated and require manual follow-up. 5) RegEx scanning uses deterministic pattern matching and may miss non-standard key formats. 6) The template uses example values for GitHub repo, Slack channel, and Jira project; replace with actual values after import.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- OpenRouter Chat Model node: connect openRouterApi credentials.
- Github Trigger On Push node: connect githubOAuth2Api credentials.
- Fetch - Commit Changes From Github node: connect HTTP Header Auth credentials.
- Fetch - Commit Changes From Github node: connect githubOAuth2Api credentials.
- Get - UserName From AWS node: connect aws credentials.
- Revoke AccessKey On AWS node: connect aws credentials.
- Send a message notification-1 node: connect Slack API credentials.
- Send a message notification-2 node: connect Slack API credentials.
- Send a message notification-3 node: connect Slack API credentials.
- Create an issue for leaked key node: connect jiraSoftwareCloudApi credentials.
- Create an issue for exposed database url node: connect jiraSoftwareCloudApi credentials.
Configuration to replace
- Source template is n8n public workflow #15314 (~26 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-24
Steps
Configure trigger and code extraction
Import the template into n8n. Configure the GitHub Trigger node: select the repository and push event, using oAuth2 authentication. The Code node parses the webhook body to extract added/modified files from the commit and builds raw URLs. The HTTP Request node fetches raw file contents using the githubOAuth2Api credential.
Regex scan, deduplication, and aggregation
The Code node (RegEx Scanner) runs regex matches against file contents: AKIA[0-9A-Z]{16} for AWS keys; sk_live_/pk_test_ patterns for payment processor keys; postgres:// and similar protocols for database URLs. Results are hashed by a Code node, then checked against the processed_secrets DataTable (rowNotExists). Unprocessed items are aggregated into a single data object.
AI classification and response decision
The AI Agent node (AI - Classifier) connects to the OpenRouter Chat Model (anthropic/claude-sonnet-4.6). Aggregated leak data is passed to the AI, with a systemMessage defining the security analyst role and requiring STRICT JSON output selecting one of four actions. The Code - Formatter node parses JSON blocks from the AI output for downstream use.
Execution prompt · Source text。AI - Classifier node text field (user message)
=A GitHub commit triggered the secret leak detector. Detected secrets: {{ JSON.stringify($json.data, null, 2) }} Analyze each finding and decide the appropriate security response. Return JSON only.Execution prompt · Source text。AI - Classifier node options.systemMessage field
You are a Security Incident Response Analyst. You receive detected secrets from a Git commit. Detection is already verified. Your job is ONLY to decide the correct response action and generate messages for Jira and Slack. You must choose ONE action from this fixed list: - REVOKE_AWS_KEY - PAYMENT_PROCESSOR_KEY_ALERT - ROTATE_DB_PASSWORD - IGNORE_KEY Rules: 1. If detected_type = AWS_ACCESS_KEY → action = REVOKE_AWS_KEY 2. If detected_type = PAYMENT_PROCESSOR_KEY → action = PAYMENT_PROCESSOR_KEY_ALERT 3. If detected_type = DATABASE_URL → action = ROTATE_DB_PASSWORD 4. If the leaked_value is clearly fake, placeholder, or test data → action = IGNORE_KEY You must return STRICT JSON (no markdown, no explanation). For EACH detected item, return: { "leaked_value": "...", "hash_leaked_value": "...", "detected_type": "...", "action": "...", "jira_tickets": "...", "slack_message": "..." } The jira_tickets field must be a short title + description. The slack_message must be a short urgent security alert. Do not return arrays. Return one JSON object per input item.Switch-branch automated response
The Switch node routes by action field: REVOKE_AWS_KEY calls AWS IAM GetAccessKeyLastUsed to obtain the username, then UpdateAccessKey to set the key to Inactive, sends a Slack alert, and saves to DataTable. PAYMENT_PROCESSOR_KEY_ALERT and ROTATE_DB_PASSWORD branches each create a Jira Task and send a Slack alert, then save to DataTable. IGNORE_KEY ends the workflow. Slack messages use the AI-generated slack_message field. Node expression (Slack): ``` ={{ $('Switch').item.json.slack_message }} ```
Prompt you can copy
Setup guidance · Editorial suggestion。Hand to setup assistant: confirm n8n instance, credential permissions, and DataTable exist before configuring nodes
This block is the prompt. Ads are never placed here.
The AI node's systemMessage hardcodes four response rules; extending detection types requires同步 updating both the RegEx Scanner and the systemMessage rule mapping.
Source
Detect and remediate leaked secret on repo with GitHub, AWS, Jira, Slack, Claude · taiwo · n8n.io · 2026-04-26
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.