Safeguard
Application Security•

CWE-278 Insecure Preserved Inherited Permissions in Archives

CWE-278 is when a program silently keeps unsafe permissions from a source such as an archive. See how it happens and how to extract files safely.

Safeguard Security Team
2 min read

CWE-278, Insecure Preserved Inherited Permissions, describes a product that inherits insecure permissions for an object, for example when copying from an archive file, without the user knowing or being involved.

It affects installers, extraction tools, backup and restore utilities, and any code that unpacks files from an outside source.

How it happens

Archive formats such as tar can record file modes and ownership. A tool that restores those values faithfully will recreate a world-writable file even if the user never intended it. The user sees a successful extraction and has no idea the result is permissive.

MITRE's example, CVE-2005-1724 (Gold), is a product that does not obey the specified permissions when exporting.

What an attacker gains

MITRE lists confidentiality and integrity impact: reading and modifying application data. Another local user can read files that should be private, or replace a file that will later be executed or trusted.

How to find it

  • After extracting or restoring, list modes and look for group or world write bits.
  • Compare the modes in the archive with what your policy allows.
  • Review installer scripts for blanket permission restoration.
tar -tvf package.tar | grep -E '^.{8}w'

How to fix it

  • Extract with options that do not preserve source permissions, then set explicit modes yourself.
  • Apply a restrictive umask before extraction.
  • Validate modes of unpacked files before using them.
umask 027
tar -xf package.tar --no-same-permissions

Quick check

Why not just trust the archive's recorded modes?

The archive may come from someone else, and the modes it records may be broader than your policy. Restoring them blindly can silently expose files.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.