Summary
A code injection vulnerability in Fooocus evaluates attacker-controlled style data extracted from image metadata. A remote attacker who can submit a crafted image may execute arbitrary Python code in the privileges of the Fooocus process.
Affected context
The vulnerability occurs in Fooocus deployments that process uploaded images and extract EXIF metadata for style handling. It becomes risky when metadata-derived values reach the get_list function and are evaluated as Python expressions without being treated strictly as untrusted data.
Exploit preconditions
- Attack surface: Image upload and metadata-processing functionality exposed by the Fooocus service
- Required access: Ability to submit an image for processing; additional authentication requirements depend on deployment configuration
- Trigger point: Processing of the image's EXIF styles value by the metadata parser
- Why exploitation is possible: Attacker-controlled metadata reaches an
eval()call, allowing input to be interpreted as executable Python code
Why this happens
The underlying issue is direct evaluation of untrusted input using Python's eval() function. This insecure pattern converts metadata content into executable code rather than treating it as ordinary data, mapping to CWE-94: Improper Control of Generation of Code. Validation performed after evaluation cannot reliably prevent execution because interpretation occurs first.
Potential impact
- An attacker may execute arbitrary Python code within the Fooocus process
- The attacker could read, modify, or delete data accessible to that process
- Application credentials, environment variables, or service tokens may be exposed
- The compromised service may be used for further internal access or disruption
- Host or container impact could increase if excessive privileges are available
General mitigation guidance
Mitigation generally focuses on removing dynamic code evaluation from metadata-processing paths and reducing trust in uploaded content.
Common defensive patterns include:
- Replacing
eval()with explicit parsing of an allowlisted data format - Accepting only the expected style types, structures, and values through strict schema validation
- Treating EXIF and other file metadata as untrusted input regardless of upload origin
- Isolating image processing in a restricted worker with minimal filesystem and network privileges
- Running the service without unnecessary operating-system, cloud, or container permissions
- Applying resource limits and controlling outbound network access for processing workloads
How teams detect issues like this
Organizations can identify similar risks through:
- Static analysis rules that flag
eval(), dynamic execution, and equivalent interpreter APIs - Code review checks for metadata, file contents, or request parameters flowing into execution functions
- Taint-analysis policies that track uploaded-file data into dynamic evaluators
- Runtime monitoring for unexpected child processes, outbound connections, or access to sensitive files
- CI policies that reject unsafe dynamic evaluation in request and file-processing code
Automated security review tools may help identify dangerous data flows, but findings should be validated against the application's actual execution paths.

