/

CVE-2026-33202

Severity:

CRITICAL RISK

(9.1)

Injection in Rails Active Storage DiskService

CVE-2026-33202

Analyzed

Vulnerability type

Category:

Injection

CWE:

CWE-74

Impact:

Arbitrary File Deletion within Storage Directory

Severity:

CRITICAL RISK

(9.1)

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

Active Storage's DiskService#delete_prefixed method previously passed blob keys directly into Dir.glob without escaping wildcard characters.

When blob keys contain attacker-controlled glob metacharacters, this can lead to deletion of unintended files within the storage directory.

Affected context

This vulnerability affects Rails applications using Active Storage with the Disk service backend where blob keys can contain user-influenced values or custom-generated keys that are not strictly sanitized.

The issue occurs during cleanup operations that rely on delete_prefixed, which uses Dir.glob to identify files to remove.

Environments where application logic or configuration allows special characters such as *, ?, [, or { in blob keys are particularly exposed, because these characters are interpreted as glob patterns rather than literal file names.

Exploit preconditions

  • Attack surface: Active Storage operations that trigger DiskService#delete_prefixed on the local filesystem.
  • Required access: Ability to influence or control blob keys (directly or indirectly), or to cause the application to generate blob keys containing glob metacharacters.
  • Trigger point: Invocation of delete_prefixed (e.g., cleanup, purge, or cascading deletes) that passes a crafted key prefix into Dir.glob.
  • Why exploitation is possible: The method forwards blob keys directly to Dir.glob without escaping glob metacharacters, causing the filesystem search to match a broader set of files than intended, and then delete them.

Why this happens

The underlying issue is the injection of untrusted input into a filesystem pattern-matching API without proper neutralization, aligning with CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.

Instead of treating blob keys as literal directory or file name fragments, DiskService#delete_prefixed used them as raw glob patterns, allowing wildcard expansion.

This insecure pattern emerges whenever application-controlled data is passed into interpreters (such as shells, SQL engines, or file pattern matchers like Dir.glob) without escaping or constraining special characters, resulting in overbroad actions on the downstream component.

Potential impact

  • Deletion of additional files within the Active Storage directory beyond the intended blobs.
  • Accidental removal of other tenants' files in multi-tenant setups sharing a storage directory.
  • Potential loss of critical application assets or user-uploaded data stored under the same root path.
  • Service disruption due to missing files required for normal application behavior.
  • Data integrity issues, including partial or inconsistent datasets for end users.

General mitigation guidance

Mitigation centers on ensuring that blob identifiers are treated strictly as data, not as patterns or commands.

Recommended defensive patterns include:

  • Escaping or neutralizing glob metacharacters before passing any user-influenced value to Dir.glob or similar pattern APIs.
  • Restricting the character set for blob keys to a safe, minimal alphabet (e.g., alphanumeric plus a short whitelist of separators).
  • Encapsulating file operations behind well-reviewed utility functions that always use safe, literal matching semantics instead of raw globs for untrusted inputs.
  • Isolating storage directories and enforcing least-privilege filesystem permissions so that even if pattern expansion misbehaves, the blast radius is limited.
  • Using logical identifiers for blobs (e.g., UUIDs) that are decoupled from any user-supplied strings.

How teams detect issues like this

Detection typically involves a combination of static and review-based checks:

  • Static analysis rules that flag uses of Dir.glob, Dir[], or other pattern-matching APIs where arguments may contain user-controllable data.
  • Code review checklists that explicitly question any use of filesystem globs and require justification when inputs are not strictly constant or from trusted sources.
  • Logging and monitoring for unusual spikes in file deletions or errors related to missing blobs, which can indicate unintended deletions.
  • Periodic security-focused scans of the codebase using automated tools to identify injection risks into shell, database, or filesystem interpreters.
  • Tests that simulate blob keys with special characters and verify that deletion routines affect only the expected files.

Sources

SourceLink
github.comgithub.com/rails/rails/commit/8c9676b803820110548cdb7523800db43bc6874c
github.comgithub.com/rails/rails/commit/955284d26e469a9c026a4eee5b21f0414ab0bccf
github.comgithub.com/rails/rails/commit/fa19073546360856e9f4dab221fc2c5d73a45e82
github.comgithub.com/rails/rails/releases/tag/v7.2.3.1
github.comgithub.com/rails/rails/releases/tag/v8.0.4.1
github.comgithub.com/rails/rails/releases/tag/v8.1.2.1
github.comgithub.com/rails/rails/security/advisories/GHSA-73f9-jhhh-hr5m

Frequently asked

questions

Yes, in scenarios where remote users can influence blob keys or cause the application to generate keys containing glob metacharacters, they can indirectly trigger unintended file deletions via standard application workflows.

The attacker needs logical access sufficient to create or control blobs or related identifiers that feed into delete_prefixed. This often corresponds to the ability to upload files, manipulate metadata, or exploit application logic that incorporates user data into blob keys.

The safest pattern is to treat all blob keys as opaque data and ensure they are passed to filesystem APIs using literal semantics. This typically means escaping glob metacharacters before calling Dir.glob or replacing glob-based deletion with direct, deterministic file path construction that does not interpret special characters.

Organizations can prevent similar bugs by enforcing secure coding guidelines for all interactions with interpreters (shells, SQL, file globs), limiting character sets for identifiers, adding static analysis rules for injection sinks, and including injection-focused checks in code review processes for any file, command, or query construction logic.

Find out what's already
exploitable in your codebase.