Mitigation Strategy: Pin Dependencies (as used by fpm
)
-
Mitigation Strategy: Pin Dependencies (as used by
fpm
)-
Description:
- Identify Dependencies: List all direct dependencies in your project's dependency specification file (e.g.,
Gemfile
for Ruby,requirements.txt
for Python) thatfpm
will use. - Specify Exact Versions: For each dependency, specify the exact version number. Instead of
gem 'sinatra'
, usegem 'sinatra', '2.2.3'
. Avoid version ranges or no specifier. - Generate Lockfile: Use the appropriate tool (e.g.,
bundle install
for Ruby,pip freeze > requirements.txt
orpipenv
/poetry
for Python) to generate a lockfile. - Commit Lockfile: Commit the lockfile (e.g.,
Gemfile.lock
,requirements.txt
,Pipfile.lock
) to version control. - Ensure
fpm
Uses Lockfile:fpm
should automatically use the lockfile if it exists and is appropriate for the input type (e.g.,-s gem
will useGemfile.lock
). This ensuresfpm
pulls the exact versions specified, not just any matching version. There's no explicitfpm
flag for this; it's inherent in howfpm
handles different input types.
- Identify Dependencies: List all direct dependencies in your project's dependency specification file (e.g.,
-
Threats Mitigated:
- Dependency Confusion/Substitution (High Severity):
fpm
will not pull in a malicious package with a higher version number from a public repository if the exact version is pinned and locked. - Supply Chain Attacks on Dependencies (High Severity):
fpm
will use the known-good, locked versions of dependencies, even if a newer, compromised version is published. - Unintentional Breaking Changes (Medium Severity):
fpm
will consistently use the same dependency versions, preventing unexpected behavior.
- Dependency Confusion/Substitution (High Severity):
-
Impact:
- Dependency Confusion/Substitution: Risk significantly reduced (almost eliminated when combined with private repositories, but even without, pinning prevents
fpm
from grabbing the wrong version). - Supply Chain Attacks on Dependencies: Risk significantly reduced;
fpm
is locked to specific, known-good versions. - Unintentional Breaking Changes: Risk eliminated;
fpm
uses consistent versions.
- Dependency Confusion/Substitution: Risk significantly reduced (almost eliminated when combined with private repositories, but even without, pinning prevents
-
Currently Implemented:
- Example: Partially.
Gemfile
uses some version pinning, butrequirements.txt
uses loose versioning. Lockfiles are generated but not consistently checked.
- Example: Partially.
-
Missing Implementation:
- Example:
requirements.txt
needs strict version pinning. CI/CD should fail if lockfiles are out-of-date, ensuringfpm
always uses the locked versions.
- Example:
-
Mitigation Strategy: Controlled Input Source (for fpm
)
-
Mitigation Strategy: Controlled Input Source (for
fpm
)-
Description:
- Identify
fpm
Input: Identify all sources of input directly provided tofpm
commands (e.g., directories with-s dir
, files, command-line arguments). - Restrict Sources: Limit these input sources to trusted locations. Ideally, this is a dedicated build directory within a CI/CD pipeline, populated only with files from your version control system.
- Avoid Untrusted Input: Never run
fpm
directly on untrusted user-supplied input (e.g., a directory uploaded by a user). If user input is indirectly involved (e.g., influencing the contents of a build directory), sanitize and validate it before it affects the input tofpm
. - CI/CD Integration: Use a CI/CD pipeline to automate the
fpm
build process. This ensuresfpm
receives a consistent, controlled set of inputs, pulled from version control and processed in a defined environment. The CI/CD pipeline itself becomes the "controlled source."
- Identify
-
Threats Mitigated:
- Path Traversal (High Severity): Prevents attackers from using malicious input to
fpm
(e.g., a crafted directory structure) to access files outside the intended build directory. - Arbitrary File Inclusion (High Severity): Reduces the risk of
fpm
including malicious files in the package if the input source is compromised. - Code Injection (Critical Severity): If input files to
fpm
contain code (e.g., scripts), this mitigates the risk of malicious code being injected through that input.
- Path Traversal (High Severity): Prevents attackers from using malicious input to
-
Impact:
- Path Traversal: Risk significantly reduced;
fpm
operates within a controlled environment. - Arbitrary File Inclusion: Risk significantly reduced;
fpm
's input is restricted. - Code Injection: Risk significantly reduced;
fpm
's input comes from a trusted source (version control).
- Path Traversal: Risk significantly reduced;
-
Currently Implemented:
- Example: Partially.
fpm
is usually run in CI/CD, but manual builds exist.
- Example: Partially.
-
Missing Implementation:
- Example: Eliminate all manual
fpm
invocations. Ensure the CI/CD pipeline is the only way packages are built withfpm
. Add input validation within the CI/CD pipeline to check for suspicious file names or content beforefpm
is invoked.
- Example: Eliminate all manual
-
Mitigation Strategy: Keep fpm
Updated
-
Mitigation Strategy: Keep
fpm
Updated-
Description:
- Monitor Releases: Regularly check for new
fpm
releases (GitHub, RubyGems.org). - Update Command: When a new version is available, update
fpm
. This is typically done viagem update fpm
(if installed as a gem) or your system's package manager. This directly impactsfpm
's behavior. - Test After Update: After updating
fpm
, run your test suite to ensure no regressions were introduced.
- Monitor Releases: Regularly check for new
-
Threats Mitigated:
- Vulnerabilities in
fpm
Itself (Variable Severity): Reduces the risk of exploiting known vulnerabilities withinfpm
. These could allow an attacker to control the build or the resulting package.
- Vulnerabilities in
-
Impact:
- Vulnerabilities in
fpm
Itself: Risk reduced (depends on the specific vulnerabilities patched).
- Vulnerabilities in
-
Currently Implemented:
- Example: Partially.
fpm
is updated periodically, but not automatically.
- Example: Partially.
-
Missing Implementation:
- Example: Automate checking for new
fpm
releases and updating it in the development environment and CI/CD pipeline.
- Example: Automate checking for new
-
Mitigation Strategy: Minimize and Review Scripts (used by fpm
)
-
Mitigation Strategy: Minimize and Review Scripts (used by
fpm
)-
Description:
- Identify Scripts: Identify all pre/post-install/uninstall scripts that
fpm
will include in the generated package. These might be explicitly provided tofpm
(e.g., using--before-install
,--after-install
flags) or implicitly generated byfpm
based on the input type (e.g., from acontrol
file in a Debian source directory). - Justify Necessity: For each script, determine if it's absolutely required. Can the functionality be achieved declaratively (e.g., through package dependencies or configuration files)?
- Simplify: If a script is necessary, keep it as short and simple as possible. Avoid complex logic.
- Review for Vulnerabilities: Thoroughly review each script for:
- Shell Injection: Ensure user input is never used directly in shell commands without proper escaping. Use parameterized commands or libraries.
- Hardcoded Credentials: Never store credentials in scripts. Use environment variables or secure configuration.
- Unnecessary Privileges: Scripts should run with the minimum necessary privileges. Avoid running as root unless absolutely required.
- External Calls: Minimize/eliminate calls to external commands (e.g.,
curl
,wget
). If unavoidable, verify downloaded resource integrity (checksums).
- Provide to fpm securely: When providing scripts to fpm (using flags like
--before-install
), ensure the script files themselves come from a trusted source (version control). - Automated checks: Use linters and static analysis tools to automatically check for common scripting errors and vulnerabilities.
- Identify Scripts: Identify all pre/post-install/uninstall scripts that
-
Threats Mitigated:
- Arbitrary Code Execution (Critical Severity): Reduces the risk of an attacker injecting malicious code into scripts that
fpm
includes in the package, which are then executed during installation. - Privilege Escalation (High Severity): Prevents scripts included by
fpm
from running with unnecessary privileges. - Information Disclosure (Medium Severity): Reduces the risk of sensitive information leaks through scripts included by
fpm
.
- Arbitrary Code Execution (Critical Severity): Reduces the risk of an attacker injecting malicious code into scripts that
-
Impact:
- Arbitrary Code Execution: Risk significantly reduced (but not eliminated, as scripts might still exist).
- Privilege Escalation: Risk significantly reduced.
- Information Disclosure: Risk reduced.
-
Currently Implemented:
- Example: Partially. Some scripts exist, but they haven't been thoroughly reviewed.
-
Missing Implementation:
- Example: Comprehensive script review is needed. Simplify scripts. Add automated checks for scripting vulnerabilities to the CI/CD pipeline before
fpm
is invoked.
- Example: Comprehensive script review is needed. Simplify scripts. Add automated checks for scripting vulnerabilities to the CI/CD pipeline before
-