Auto-Remediate Critical Attack Paths in Neo4j Security Graph
Input: Neo4j security graph + GitHub IaC repo; Process: scheduled scan → path scoring → AI-generated fix → Jira ticket → GitHub PR; Output: remediated IaC file with linked ticket
- Who
- Security ops or platform engineers with n8n experience, maintaining a Neo4j security graph, Jira, and GitHub repos
- You get
- Automatically discover high-risk attack paths from internet-facing to crown-jewel assets, generate fixes, and create Jira tickets and GitHub PRs
- You need
- n8n · neo4j · jira · github
Constraints
Prerequisites: n8n instance (self-hosted or enterprise recommended); Neo4j database with Asset nodes carrying properties: name, exposure, criticality, exposedPorts, iacResourceAddress, iacFilePath, resourceType; GitHub repo with mutable IaC files; Jira Software Cloud project; OpenAI API key. Credentials: Neo4j HTTP Basic Auth, GitHub API (repo scope), Jira Software Cloud API (email + token), OpenAI API. Costs: OpenAI per-token; n8n/GitHub/Jira per platform pricing. Risks: AI-generated fixes require human review before merge; continueOnFail is enabled on multiple nodes—failures won't halt the workflow but may produce empty downstream data, so check execution logs.
What they did
Template author oneclick-ai built a 26-node n8n workflow integrating a Neo4j security graph, OpenAI GPT-4.1-mini, Jira, and GitHub APIs. The workflow triggers on schedule or manually, queries Neo4j for shortest paths from internet-facing to crown-jewel assets, extracts and scores them, automatically fetches the relevant IaC file, has an AI generate a fix, then creates a Jira ticket, a GitHub remediation branch and PR, and posts the PR link back to Jira.
How it went
The source claims the template automatically identifies and remediates the riskiest attack paths (author_report). Published on n8n.io with 15 views; no independent execution logs or remediation case studies are provided.
Worth knowing
1) Multiple HTTP Request and Code nodes have continueOnFail=true—individual failures won't halt the workflow but may pass empty data downstream; review execution logs. 2) The AI-generated updatedFileContent replaces the entire file; validate in a test repo before enabling auto-commit. 3) The scoring logic hardcodes high_risk_ports (22, 3389, 445, etc.); adjust if your environment uses non-standard ports. 4) No Neo4j schema initialization script is provided—Asset node properties must be maintained separately. 5) The template uses gpt-4.1-mini; other models in the same series may work but output format compatibility should be tested.
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
- Post to Security Graph API node: connect HTTP Basic Auth credentials.
- Retrieve IaC File from GitHub node: connect GitHub API credentials.
- OpenAI GPT-4.1 Mini Agent node: connect OpenAI API credentials.
- Submit Jira Issue API node: connect jiraSoftwareCloudApi credentials.
- Fetch GitHub Base Branch Reference node: connect GitHub API credentials.
- Create New GitHub Branch node: connect GitHub API credentials.
- Update IaC File on Branch node: connect GitHub API credentials.
- Propose Pull Request on GitHub node: connect GitHub API credentials.
- Post PR Link to Jira node: connect jiraSoftwareCloudApi credentials.
Configuration to replace
- Source template is n8n public workflow #18096 (~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-25
Steps
Configure credentials and global parameters
After importing the template into n8n: 1) Add Neo4j HTTP Basic Auth credentials to the 'Post to Security Graph API' node; 2) Add GitHub API credentials (repo scope) to all GitHub HTTP Request nodes; 3) Add Jira Software Cloud credentials (email + API token) to both Jira HTTP Request nodes; 4) Add OpenAI API key to the 'OpenAI GPT-4.1 Mini Agent' node; 5) Update values in 'Set Configuration Parameters': neo4jUrl, riskScoreThreshold, jiraBaseUrl, jiraProjectKey, repoOwner, repoName, baseBranch, defaultIacPath.
Trigger scan and query the security graph
The workflow starts via 'When Daily Graph Scan Starts' (default cron 0 5 * * *, daily at 05:00) or 'When Test Run Initiated' (manual). After loading config, 'Post to Security Graph API' sends a Cypher query to Neo4j /db/neo4j/tx/commit: MATCH shortestPath from internet-facing Asset to Assets with criticality in ['crown-jewel','critical'], returning path, source/target names, hop count, limited to 25 results.
Parse attack paths
'Parse and Extract Attack Paths' (Code, JS) parses the Neo4j transactional response, building one candidate attack-path object per row. Extracts sourceAsset, targetAsset, targetCriticality, hopCount, exposedPorts, misconfigResourceAddress, misconfigResourceType, misconfigFilePath, nodeCount, and merges upstream config parameters.
Score and branch on criticality
'Analyze and Rank Attack Paths' (Code, Python) performs composite risk scoring: target criticality (40) + port exposure/exploitability (25) + hop proximity (20) + blast-radius density (15). Sorts descending, picks the top path, and marks isCriticalPath=true if riskScore >= riskScoreThreshold (default 50). 'If Critical Path Detected' checks this boolean; if true, proceeds to remediation.
Fetch IaC and generate remediation
If critical: 1) 'Retrieve IaC File from GitHub' fetches the misconfigFilePath file content (base64) via GitHub API; 2) 'Remediation Strategy Agent' (AI Agent, define prompt) receives attack-path details and base64-encoded IaC, instructing the AI to identify the misconfigured resource block and output JSON with: remediationSummary, remediationSteps, updatedFileContent (complete corrected file, plain text), cvssEstimate, jiraSummary, jiraDescription, prBranchName, prTitle, prBody, commitMessage; 3) 'OpenAI GPT-4.1 Mini Agent' provides the LLM; 4) 'Parse AI and Build Payloads' (Code, JS) parses the AI output, strips markdown fences, and prepares Jira/GitHub payloads, encoding the corrected file to base64.
Execution prompt · Source text。Remediation Strategy Agent node text field (define prompt)
=You are a cloud security remediation expert. An attack path was found in the security graph and needs a concrete fix. Attack Path: - Source (internet-facing): {{ $('Analyze and Rank Attack Paths').item.json.sourceAsset }} - Target ({{ $('Analyze and Rank Attack Paths').item.json.targetCriticality }}): {{ $('Analyze and Rank Attack Paths').item.json.targetAsset }} - Hop count: {{ $('Analyze and Rank Attack Paths').item.json.hopCount }} - Exposed ports on the entry point: {{ $('Analyze and Rank Attack Paths').item.json.exposedPorts }} - Risk score: {{ $('Analyze and Rank Attack Paths').item.json.riskScore }}/100 ({{ $('Analyze and Rank Attack Paths').item.json.severity }}) - Misconfigured resource: {{ $('Analyze and Rank Attack Paths').item.json.misconfigResourceAddress }} ({{ $('Analyze and Rank Attack Paths').item.json.misconfigResourceType }}) Current IaC file ({{ $('Analyze and Rank Attack Paths').item.json.misconfigFilePath }}), base64-encoded content: {{ $json.content }} Decode the base64 content mentally, identify the specific resource block causing this attack path (overly permissive security group rule, wildcard IAM policy, public S3/network ACL, missing MFA/role trust condition, etc.), and: 1. Write a remediationSummary (2-3 sentences) explaining why this path exists. 2. Write remediationSteps: an array of 3-6 short, concrete steps. 3. Produce updatedFileContent: the COMPLETE corrected file content (plain text, not base64) applying least-privilege / closing the exposure — keep all unrelated content unchanged. 4. cvssEstimate: a number 0-10 estimating severity. 5. jiraSummary: a short ticket title. 6. jiraDescription: a 2-4 sentence ticket description. 7. prBranchName: a short kebab-case branch name. 8. prTitle: a concise PR title. 9. prBody: a markdown PR description including the attack path, the fix, and the risk score above. 10. commitMessage: a concise commit message. Return ONLY a JSON object with keys: remediationSummary, remediationSteps, updatedFileContent, cvssEstimate, jiraSummary, jiraDescription, prBranchName, prTitle, prBody, commitMessage. No markdown fences, no commentary.Create Jira tracking issue
'Submit Jira Issue API' creates an Issue via Jira REST API v3, including: project key, summary (from AI jiraSummary), issuetype (default Bug), description (Atlassian Document Format with attack path details and riskScore/severity), labels (attack-path, auto-remediation).
Prepare GitHub fix branch and PR
1) 'Fetch GitHub Base Branch Reference' gets the baseBranch git ref sha; 2) 'Create New GitHub Branch' creates a remediation branch from that sha; 3) 'Update IaC File on Branch' commits the base64-encoded corrected file to the new branch; 4) 'Propose Pull Request on GitHub' opens a PR with title/body from AI output, appending the Jira ticket link.
Post PR link back to Jira
'Post PR Link to Jira' waits for the PR creation, then adds a comment to the corresponding Jira issue: 'Auto-remediation PR opened:' + PR html_url, closing the loop between ticket and code change.
Prompt you can copy
Setup guidance · Editorial suggestion。Give to setup assistant; confirm inputs and permissions first
This block is the prompt. Ads are never placed here.
You are a cloud security automation assistant. The user wants to set up the 'Neo4j Attack Path Auto-Remediation' n8n template. First confirm they have: 1) an accessible Neo4j instance with Asset nodes and required properties; 2) write access and API credentials for a GitHub repo; 3) a Jira Software Cloud project and API credentials; 4) an OpenAI API key. Then help them import the template, configure credentials, modify URL/project/repo values in the Set node, and suggest testing with 'When Test Run Initiated' before enabling the schedule trigger.
Before setup, verify your Neo4j graph schema includes Asset node properties: name, exposure, criticality, exposedPorts, iacResourceAddress, iacFilePath, resourceType.
Source
Remediate critical attack paths with Neo4j, OpenAI, GitHub and Jira · oneclick-ai · n8n.io · 2026-08-12
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.