Skip to content

Strip bidi control characters from a sanitized attachment filename #988

Description

@pat-lewczuk

Follow-up from #957

#957 sanitizes the filename an attachment carries before it is used as a name in the per-project library (packages/contract/src/runs.ts). The strip covers C0 plus U+007F and the characters Windows refuses, but not the bidi/format control characters.

From the re-review of 3cce047a:

The strip covers C0 plus U+007F and the characters Windows refuses, but not the bidi overrides (U+202E and friends), so brief‮dm.txt files under a name that renders reversed in a file browser. Extension pinning already removes the dangerous half of that trick — the name cannot claim an extension the media type did not earn — so this is display spoofing only. One more range in the existing character class if you want it.

Display spoofing only, which is why it did not hold #957: the extension is pinned to the already-validated media type, so a name cannot claim to be something the content is not.

Acceptance criteria

  • The name sanitizer also strips bidi/format control characters (at least U+200EU+200F, U+202AU+202E, U+2066U+2069).
  • A test pins a name containing U+202E and asserts the stored name renders in one direction.

Related: #957

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

securitySecurity-sensitive

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions