For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/static_analysis/static_analysis_rules/bash-security/shebang-non-absolute-path.md. A documentation index is available at /llms.txt.

Shebang interpreter is not an absolute path

This product is not supported for your selected Datadog site. ().

Metadata

ID: bash-security/shebang-non-absolute-path

Language: Bash

Severity: Warning

Category: Security

CWE: 426

Description

A shebang should point to an absolute interpreter path immediately after #!. Relative forms such as #!bash or #!bin/sh are not rooted at / and may execute an unintended binary depending on environment configuration.

Prefer explicit absolute paths like #!/bin/bash, #!/usr/bin/bash, or #!/bin/sh to make interpreter selection predictable and reduce path-hijacking risk (CWE-426).

Non-Compliant Code Examples

#!bin/sh
echo runs via env
#!bash
true

Compliant Code Examples

#!/bin/bash
echo ok
#!/usr/bin/bash
true
echo first line is not a shebang
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security