Skip to content

Security hardening: safe previews, smb.conf injection, headers - #34

Merged
codemastervy merged 2 commits into
mainfrom
security-hardening
Nov 13, 2026
Merged

codemastervy merged 2 commits into
mainfrom
security-hardening

Conversation

@codemastervy

Copy link
Copy Markdown
Owner

Fixes found in a security review:

  • Stored XSS via inline preview – /api/files/download?inline=true served any file with its guessed type from the dashboard's origin, so an HTML or SVG file dropped on a share ran script with the admin session. Only inert types are shown inline now; the rest download, with nosniff and a sandbox CSP.
  • smb.conf directive injection – a folder name containing a newline ended up verbatim in path =. Such paths are refused and new names can't contain control characters.
  • Option injection – usernames like -x were passed to useradd/smbpasswd. Usernames must now start with a letter or _.
  • Symlink delete – deleting a symlink removed the target's contents instead of the link.
  • Security headers on all responses, unused passlib removed, actions pinned by SHA, and the bimonthly update no longer commits its report files.

82 backend tests pass, including new regression tests.

- inline preview only serves inert types (images, video, audio, PDF, plain
  text); HTML/SVG and everything else is forced to download, with nosniff
  and a sandbox CSP, so a file on a share cannot run script in the dashboard
- security headers on every response (CSP, X-Frame-Options, nosniff,
  Referrer-Policy, no-store on the API)
- refuse to share a folder whose path has control characters or '%', and
  reject control characters in new file names: a newline could inject a
  directive into the generated smb.conf
- usernames must start with a letter or underscore so they can never be
  read as an option by useradd/smbpasswd; passwords reject newlines
- deleting a symlink removes the link instead of emptying its target
- drop unused passlib dependency
- CI: pin actions by SHA, read-only token; stop the bimonthly update from
  committing its own report files
uvicorn ran with --forwarded-allow-ips=*, which let any client forge its
source address and bypass the failed-login throttle. Default is now
127.0.0.1; FORWARDED_ALLOW_IPS is documented for reverse-proxy setups.
@codemastervy
codemastervy merged commit 66c821b into main Nov 13, 2026
3 checks passed
@codemastervy
codemastervy deleted the security-hardening branch November 13, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant