artisanpack-ui/secure-uploads

File upload security for Laravel — content-type validation, filename sanitization, malware scanning (ClamAV / VirusTotal), rate limiting, secure storage, and quarantine.

Maintainers

Package info

github.com/ArtisanPack-UI/secure-uploads

pkg:composer/artisanpack-ui/secure-uploads

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 10

1.0.0 2026-05-19 19:16 UTC

This package is auto-updated.

Last update: 2026-05-19 19:31:50 UTC


README

File upload security for Laravel: content-type validation with magic-byte sniffing, filename sanitization, pluggable malware scanning (ClamAV / VirusTotal), secure signed-URL storage, upload rate limiting, and quarantine workflows.

This package is part of the ArtisanPack UI Security 2.0 split — the upload-focused features previously bundled inside artisanpack-ui/security (1.x) live here in 2.0+.

Features

  • File validation pipeline (FileValidationService) — MIME sniffing against actual file content, magic-byte verification, extension allowlists / blocklists, per-type and absolute size limits, double-extension and null-byte trick detection, EXIF stripping for images
  • Validation rulesSafeFilename, SecureFile (drop-in Rule classes for Form Requests)
  • Pluggable malware scanningClamAvScanner (Unix socket or binary), VirusTotalScanner (API + by-hash short-circuit), NullScanner (dev / CI default)
  • Secure storage (SecureFileStorageService) — files stored outside the public root, served only via signed URLs through the bundled SecureFileController
  • Quarantine workflow — files flagged by async scanning live in a quarantine area until cleared by security:scan-quarantine
  • Upload rate limiting (FileUploadRateLimiter)
  • Middlewarevalidate.upload, scan.upload
  • Eloquent concernHasSecureFiles adds attachSecureFile, secureImages, secureDocuments, etc. to any model that owns uploaded files
  • EventsFileUploaded, FileUploadRejected, FileServed, MalwareDetected (subscribed to by artisanpack-ui/security-analytics for audit trail)
  • Artisan commandssecurity:cleanup-files, security:scan-quarantine

Installation

composer require artisanpack-ui/secure-uploads
php artisan migrate

(Optional) Publish the config:

php artisan vendor:publish --tag=secure-uploads-config

Quick start

use ArtisanPackUI\SecureUploads\Concerns\HasSecureFiles;

class Post extends Model
{
    use HasSecureFiles;
}
$post = Post::find(1);
$stored = $post->attachSecureFile($request->file('attachment'));

return redirect()->route('secure-file.show', ['identifier' => $stored->identifier]);

The attachSecureFile() call runs validation, optionally scans for malware, sanitizes the filename, and stores the file behind a signed URL.

Configuration

The shipped config covers MIME / extension allow- and block-lists, size limits, EXIF stripping, scanner driver selection (null / clamav / virustotal), and rate limiting. Override any of it after publishing:

php artisan vendor:publish --tag=secure-uploads-config

See config/artisanpack/secure-uploads.php for the full list with inline documentation.

Documentation

Requirements

  • PHP 8.2+
  • Laravel 10 / 11 / 12
  • ext-fileinfo (bundled with PHP) for MIME detection
  • ClamAV daemon or binary (optional, only if using the ClamAV scanner)
  • VirusTotal API key (optional, only if using the VirusTotal scanner)

Sibling packages

Package Scope
artisanpack-ui/security-full Meta-package — pulls in the full security suite (all six packages below) in a single require
artisanpack-ui/security Core: input sanitization, output escaping, KSES, CSP, security headers
artisanpack-ui/security-auth 2FA, password complexity, account lockout, sessions
artisanpack-ui/security-advanced-auth WebAuthn, SSO, social login, biometric, device fingerprinting
artisanpack-ui/rbac Roles, permissions, hierarchy, Blade directives, Gate integration
artisanpack-ui/security-analytics Event logging, anomaly detection, SIEM, dashboards
artisanpack-ui/compliance GDPR / CCPA / LGPD compliance tools

License

MIT — see LICENSE.

Contributing

Please read the contributing guidelines before opening an issue or PR.