Skip to content

BUG: Attachment filename not sanitized for filesystem #642

@andrinoff

Description

@andrinoff

Describe the bug: Attachment filenames used directly when saving to disk. Could contain path traversal characters like "../" or invalid filesystem chars.

To reproduce:

  1. Receive email with attachment named "../../evil.txt"
  2. Save attachment
  3. May write outside intended directory

Expected behavior: Sanitize filename:

  • Strip path separators (/ )
  • Remove invalid chars for current OS
  • Limit length to filesystem max
  • Handle collisions with (1), (2) suffix

Additional context:

  • File: view/html.go or attachment handling code
  • Use filepath.Base() and validate chars
  • Severity: Medium - path traversal risk
  • Complexity: Easy - filename sanitization

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions