PHP Symfony Framework Security Audit (php-symfony-audit)
Analyze the "framework-specific security mechanisms" and "configuration/usage pitfalls" in Symfony project source code, focusing on:
- Correctness of access_control and firewalls configuration in
config/packages/security*.yaml
- CSRF protection mechanism (form submission and token validation)
- Risks of Twig rendering autoescaping and raw output
- Symfony access expressions and the security interceptor chain (mapped to AUTH/EXPR/TPL as appropriate)
- HttpClient outbound request policy (SSRF-class risks mapped to the generic SSRF type)
Input
Provided by the user:
source_path: root directory of the Symfony project source code
Optional:
output_path: output directory path (default {source_path}_audit)
Output Directory
Output to:
{output_path}/framework_audit/
symfony_{timestamp}.md
Framework Identification (Required)
You must present evidence points identifying the target as Symfony (no unsupported assertions):
- Typical directories:
config/, src/, templates/
- Dependency evidence:
symfony/framework-bundle etc. in composer.json
- Entry point evidence:
public/index.php or a similar front controller
Risk Type Mapping (Required)
Every finding must state:
- The applicable generic type code:
AUTH / CSRF / CFG / XSS / TPL / LOGIC / SESS / SSRF / EXPR etc.
- Mapping rationale: why this Symfony risk belongs to that type code (one sentence)
Mandatory Audit Checklist (Required: check each item and output the result)
1) Access Control and Authentication Policy (AUTH)
Must locate and output:
access_control rules in security.yaml
firewalls configuration (whether anonymous: true, whether stateless: true and the authentication method)
switch_user, role_hierarchy, or voter/policy-style configuration (if present)
Decision rules:
- If overly permissive rules exist (e.g. an overly generic anonymous rule covering sensitive paths), output an AUTH risk
- If a pattern of "authenticated but missing role/ownership checks" exists, output an AUTH or LOGIC risk
2) CSRF Protection (CSRF)
Must locate and output:
- Symfony CSRF-related configuration (
framework: csrf_protection or component-level configuration)
- How the CSRF token is generated and received in form type usage
- The handling path when token validation fails (early exit, or validated only in some branches)
Decision rules:
- If "some routes/forms have CSRF disabled or the CSRF token receiving field is inconsistent" exists, output a CSRF risk
3) Twig Autoescaping and Raw Output (XSS/TPL)
Must locate and output:
- Twig configuration: whether autoescaping is disabled (globally or locally)
- Raw output points in templates:
|raw, {% autoescape false %}, and any "escaping bypass" directives
- Data sources: where the variables used in raw output come from (request/session/database fields)
Decision rules:
- If a raw output variable has a controllable source and is not escaped, map it to XSS or TPL (TPL if expression execution / template engine controllability exists)
4) Security Expressions and Evaluation Risk (EXPR/TPL/AUTH)
Must locate and output:
- Where ExpressionLanguage is used for security (voter/policy
is_granted or expression conditions)
- Whether the expression string source may be user-controlled (e.g. expression concatenation)
Decision rules:
- If the expression string is controllable, output it as an EXPR or TPL risk
5) Outbound HTTP and Internal Network Access (SSRF)
Must locate and output (framework correlation checks only):
- Wrapper entry points for outbound calls such as
HttpClient/KernelInterface
- Whether the URL/host originates from user input, and whether an allowlist or internal network blocking exists
Observable PoC (Required: framework-specific observable verification harness)
Provide at least one of the following two categories and clearly state the observation point:
- Access control error: access a suspected protected route as an unauthenticated/low-privilege user and observe the response difference
- CSRF error: craft a form request with a missing or forged CSRF token and observe the status code/error path
PoC output requirements:
- Must include the real route and the real form action (or route path)
- Must state the expected observation point (e.g. whether a 403 is returned, whether the state change still proceeds)
Output Completeness Check (Mandatory)
1---2name: php-symfony-audit3description: "Symfony framework-specific security audit tool. Performs white-box static analysis of Symfony framework mechanisms such as security.yaml, CSRF, Twig/Twig raw, expressions, and access control, and maps risks to the generic vulnerability type taxonomy (AUTH/CSRF/CFG/XSS/TPL/LOGIC, etc.)."4zh-signals: "审计 Symfony 框架配置与安全机制,覆盖访问控制、CSRF、Twig raw 与安全表达式。信号:Symfony审计,security.yaml,CSRF防护,Twig转义,访问控制。"5when-to-use: >-6 Use when performing a white-box security audit of a Symfony project, especially security.yaml access_control, CSRF protection, Twig autoescaping or raw output, and ExpressionLanguage usage.7metadata:8 source: https://skillmd.com/skills/dangeroussong/php-symfony-audit9---1011# PHP Symfony Framework Security Audit (php-symfony-audit)12- 攻击大类:C09 Web应用漏洞利用1314Analyze the "framework-specific security mechanisms" and "configuration/usage pitfalls" in Symfony project source code, focusing on:15- Correctness of access_control and firewalls configuration in `config/packages/security*.yaml`16- CSRF protection mechanism (form submission and token validation)17- Risks of Twig rendering autoescaping and raw output18- Symfony access expressions and the security interceptor chain (mapped to AUTH/EXPR/TPL as appropriate)19- HttpClient outbound request policy (SSRF-class risks mapped to the generic SSRF type)2021## Input22Provided by the user:23- `source_path`: root directory of the Symfony project source code24Optional:25- `output_path`: output directory path (default `{source_path}_audit`)2627## Output Directory28Output to:29```30{output_path}/framework_audit/31 symfony_{timestamp}.md32```3334## Framework Identification (Required)35You must present evidence points identifying the target as Symfony (no unsupported assertions):36- Typical directories: `config/`, `src/`, `templates/`37- Dependency evidence: `symfony/framework-bundle` etc. in `composer.json`38- Entry point evidence: `public/index.php` or a similar front controller3940## Risk Type Mapping (Required)41Every finding must state:42- The applicable generic type code: `AUTH` / `CSRF` / `CFG` / `XSS` / `TPL` / `LOGIC` / `SESS` / `SSRF` / `EXPR` etc.43- Mapping rationale: why this Symfony risk belongs to that type code (one sentence)4445## Mandatory Audit Checklist (Required: check each item and output the result)4647### 1) Access Control and Authentication Policy (AUTH)48Must locate and output:49- `access_control` rules in `security.yaml`50- `firewalls` configuration (whether `anonymous: true`, whether `stateless: true` and the authentication method)51- `switch_user`, `role_hierarchy`, or voter/policy-style configuration (if present)5253Decision rules:54- If overly permissive rules exist (e.g. an overly generic anonymous rule covering sensitive paths), output an AUTH risk55- If a pattern of "authenticated but missing role/ownership checks" exists, output an AUTH or LOGIC risk5657### 2) CSRF Protection (CSRF)58Must locate and output:59- Symfony CSRF-related configuration (`framework: csrf_protection` or component-level configuration)60- How the CSRF token is generated and received in form type usage61- The handling path when token validation fails (early exit, or validated only in some branches)6263Decision rules:64- If "some routes/forms have CSRF disabled or the CSRF token receiving field is inconsistent" exists, output a CSRF risk6566### 3) Twig Autoescaping and Raw Output (XSS/TPL)67Must locate and output:68- Twig configuration: whether autoescaping is disabled (globally or locally)69- Raw output points in templates: `|raw`, `{% autoescape false %}`, and any "escaping bypass" directives70- Data sources: where the variables used in raw output come from (request/session/database fields)7172Decision rules:73- If a raw output variable has a controllable source and is not escaped, map it to XSS or TPL (TPL if expression execution / template engine controllability exists)7475### 4) Security Expressions and Evaluation Risk (EXPR/TPL/AUTH)76Must locate and output:77- Where ExpressionLanguage is used for security (voter/policy `is_granted` or expression conditions)78- Whether the expression string source may be user-controlled (e.g. expression concatenation)7980Decision rules:81- If the expression string is controllable, output it as an EXPR or TPL risk8283### 5) Outbound HTTP and Internal Network Access (SSRF)84Must locate and output (framework correlation checks only):85- Wrapper entry points for outbound calls such as `HttpClient`/`KernelInterface`86- Whether the URL/host originates from user input, and whether an allowlist or internal network blocking exists8788## Observable PoC (Required: framework-specific observable verification harness)89Provide at least one of the following two categories and clearly state the observation point:90- Access control error: access a suspected protected route as an unauthenticated/low-privilege user and observe the response difference91- CSRF error: craft a form request with a missing or forged CSRF token and observe the status code/error path9293PoC output requirements:94- Must include the real route and the real form action (or route path)95- Must state the expected observation point (e.g. whether a 403 is returned, whether the state change still proceeds)9697## Output Completeness Check (Mandatory)98- [ ] Output includes: Symfony identification evidence points99- [ ] All five blocks (AUTH/CSRF/Twig(raw)/security expressions/HttpClient(optional)) have check results100- [ ] Every risk has: a mapped type code + location evidence + an observable verification harness + a remediation recommendation