/

CVE-2026-51974

Severity:

HIGH RISK

(8.8)

Code Injection (CWE-94) in Fooocus Metadata Parser

CVE-2026-51974

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.

Sources

SourceLink
github.comgithub.com/lllyasviel/Fooocus/blob/main/modules/meta_parser.py#L89
github.comgithub.com/lllyasviel/Fooocus/issues/4115
mrbruh.commrbruh.com/fooocus/

Frequently asked

questions

It may be remotely exploitable when an attacker can reach an image-upload or image-processing interface that handles the affected metadata. Whether authentication is required depends on the deployment's access controls.

The key requirement is the ability to submit an image whose metadata is processed by the vulnerable code path. No direct shell access is inherently required.

Remove dynamic evaluation and parse styles using a strict, allowlisted data format with validation before any application logic consumes the values.

Treat uploaded files and metadata as untrusted, prohibit dynamic execution in parsers, use least-privilege service accounts, and combine static analysis with runtime monitoring.

Find out what's already
exploitable in your codebase.