Course contentsShow
← Security
Lesson 953 of 3,05220. Web Security - File Upload and ProcessingFree lesson

Server-Side File Overwrite Vulnerabilities

Exploiting predictable filenames or missing access controls to overwrite critical system files or application configurations.

Server-Side File Overwrite Vulnerabilities

What you'll learn: How attackers exploit predictable filenames or weak access controls to overwrite critical system files, potentially taking control of an application.

What Is a File Overwrite Vulnerability?

When an application accepts file uploads without properly validating filenames or storage locations, attackers can overwrite existing files on the server. Unlike simply uploading malicious content, this attack targets where files get stored, replacing legitimate files with malicious ones.

Think of it like a valet parking service that lets you choose your own parking spot number. If you pick spot #1 (where the owner's car is parked), you could replace their vehicle with yours—and they'd drive away in your car thinking it's theirs.

How Attackers Exploit This

Predictable Filename Patterns: If an application saves uploaded files using predictable names like user_123_profile.jpg or timestamps, attackers can guess these names and intentionally overwrite them.

Path Traversal in Filenames: Attackers submit filenames like ../../config/database.ini or ../../../etc/passwd to write outside the intended upload directory, potentially overwriting configuration files, authentication databases, or even executable code.

Missing Access Control: Without proper permission checks, attackers might overwrite files belonging to other users, administrative configuration files, or application source code files that get executed directly (like .php or .jsp files).

Real-World Impact

  • Overwriting .htaccess files to disable security rules
  • Replacing configuration files to inject database credentials or API keys
  • Overwriting user avatars to conduct phishing attacks
  • Replacing executable scripts with backdoors

Key Takeaway: Always generate unique, unpredictable filenames on the server side, store uploads outside the web root, validate and sanitize all path components, and enforce strict access controls to prevent unauthorized file overwrites.