API Reference Sobelow v0.18.1

View Source

Modules

Sobelow is a static analysis tool for discovering vulnerabilities in Phoenix applications.

Command Injection

Command Injection vulnerabilities are a result of passing untrusted input to an operating system shell, and may result in complete system compromise.

Command Injection in :os.cmd

This submodule of the CI module checks for Command Injection vulnerabilities through usage of the :os.cmd function.

Command Injection via System

This submodule of the CI module checks for Command Injection vulnerabilities through usage of the System.cmd function.

Configuration

Submodules contained within this vulnerability type are related to common insecurities found in how Phoenix applications are configured.

Missing Content-Security-Policy

Content-Security-Policy is an HTTP header that helps mitigate a number of attacks, including Cross-Site Scripting.

Cross-Site Request Forgery

In a Cross-Site Request Forgery (CSRF) attack, an untrusted application can cause a user's browser to submit requests or perform actions on the user's behalf.

Cross-Site Request Forgery

In a Cross-Site Request Forgery (CSRF) attack, an untrusted application can cause a user's browser to submit requests or perform actions on the user's behalf.

Cross-Site Websocket Hijacking

Websocket connections are not bound by the same-origin policy. Connections that do not validate the origin may leak information to an attacker.

HSTS

The HTTP Strict Transport Security (HSTS) header helps defend against man-in-the-middle attacks by preventing unencrypted connections.

HTTPS

Without HTTPS, attackers in a privileged network position can intercept and modify traffic.

Missing Secure HTTP Headers

By default, Phoenix HTTP responses contain a number of secure HTTP headers that attempt to mitigate XSS, click-jacking, and content-sniffing attacks.

Hard-coded Secrets

In the event of a source-code disclosure via file read vulnerability, accidental commit, etc, hard-coded secrets may be exposed to an attacker. This may result in database access, cookie forgery, and other issues.

Disabled TLS certificate verification

Reports literal verify: :verify_none in TLS options, including Gun's tls_opts map entries. It also catches hackney's :insecure and insecure: true options and the direct verify option in WebTransport connections. Disabling verification lets an attacker impersonate the remote server. Use :verify_peer and a trusted CA, including for self-signed services.

Legacy TLS and SSL protocol versions

Explicit SSL 2/3, TLS 1.0/1.1 and DTLS 1.0 selections in TLS versions options receive high confidence. These legacy protocols should be removed from both client and server configurations; use TLS 1.2 or 1.3 as required by the protocol. DTLS 1.2 is not flagged.

Cryptography

Checks literal hash and cipher algorithm choices. These checks do not prove that a cryptographic construction is secure.

Weak ciphers and unauthenticated encryption

DES, 3DES, RC2, RC4, Blowfish and ECB modes receive high confidence. Prefer authenticated encryption such as AES-GCM or ChaCha20-Poly1305.

Weak or inappropriate hashing

MD4, MD5 and SHA-1 are unsuitable when collision resistance is required. RIPEMD-160 is reported as a legacy choice, not as a proven collision break. Prefer SHA-256 or stronger for security-sensitive digests. Non-security checksums and cache keys may legitimately use legacy hashes.

Weak digests in digital signatures

MD5 and SHA-1 lack the collision resistance required for new digital signatures. Prefer a modern signature scheme and an appropriate digest such as SHA-256 or stronger. HMAC is a different construction and is not classified by this check.

Denial of Service

The Denial of Service (DOS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed.

Denial of Service via Unsafe Atom Interpolation

In Elixir, atoms are not garbage collected. As such, if user input is used to create atoms (as in :"foo#{bar}", or in :erlang.binary_to_atom), it may result in memory exhaustion. Prefer the String.to_existing_atom function for untrusted user input.

Atom exhaustion through Erlang term files

:file.consult/1 and :file.path_consult/2 parse Erlang terms from a text file. Untrusted contents can create arbitrary atoms and exhaust VM resources. These functions have no :safe option. They parse terms; they do not evaluate arbitrary expressions like :file.eval/1.

Atom exhaustion through decoders

Jason and Poison can create new atoms with keys: :atoms. YamlElixir's string readers can create atoms with atoms: true. Decoding untrusted input with these options can exhaust the VM's atom table because atoms are not garbage collected.

Denial of Service via List.to_atom and :erlang.list_to_atom

In Elixir, atoms are not garbage collected. As such, if user input is passed to the List.to_atom function, or to its Erlang equivalent :erlang.list_to_atom, it may result in memory exhaustion. Prefer the List.to_existing_atom function for untrusted user input.

Atom exhaustion through dynamic module names

Module.concat/1,2 creates module-name atoms. Unbounded names derived from request input can exhaust the VM's atom table, even if no module is loaded under those names. Atoms are not garbage collected.

Denial of Service via String.to_atom

In Elixir, atoms are not garbage collected. As such, if user input is passed to the String.to_atom function, it may result in memory exhaustion. Prefer the String.to_existing_atom function for untrusted user input.

IO helpers. Mostly mirror Mix.Shell.IO, but Mix will not always be available to Sobelow.

Miscellaneous

This suite of tests is to be a catch-all for checks that don't fall neatly into the other detection categories.

Insecure use of binary_to_term

Decoding untrusted Erlang terms without :safe can create atoms and exhaust VM resources. The :safe option prevents new atoms, but still permits executable terms. Decoding a function does not itself execute it; later application code may invoke it, including indirectly via protocols.

Insecure use of File and Path

Note: This check has been deprecated. File/Path issues were addressed with the release of OTP 21.

Remote Code Execution

Remote Code Execution vulnerabilities are a result of untrusted user input being executed or interpreted by the system and may result in complete system compromise.

Code Execution in eval function

Arbitrary strings passed to the Code.eval_* functions can be executed as malicious code.

Code execution through compilation and loading

Code.compile_string/1,2 and Code.compile_quoted/1,2 execute code while compiling it. Code.compile_file/1,2 and Code.require_file/1,2 compile and execute a source file; requiring a file only once does not make its contents trusted. Use these APIs only with trusted application code.

Insecure EEx evaluation

If user input is passed to EEx eval functions, it may result in arbitrary code execution. The root cause of these issues is often directory traversal.

Code execution through Erlang files

:file.eval/1,2, :file.script/1,2, :file.path_eval/2 and :file.path_script/2,3 read and execute Erlang expressions from a file. Only execute trusted application files. Avoid selecting executable files using request input, uploaded files or attacker-writable directories.

SQL Injection

SQL Injection occurs when untrusted input is interpolated directly into a SQL query. In a typical Phoenix application, this would mean using the Ecto.Adapters.SQL.query method and not using the parameterization feature.

SQL Injection in Query

This submodule of the SQL module checks for SQL injection vulnerabilities through usage of the Ecto.Adapters.SQL.query and Ecto.Adapters.SQL.query!.

SQL Injection in Stream

This submodule of the SQL module checks for SQL injection vulnerabilities through usage of the Ecto.Adapters.SQL.stream.

Path Traversal

Path traversal vulnerabilities are a result of interacting with the filesystem using untrusted input. This class of vulnerability may result in file disclosure, code execution, denial of service, and other issues.

Directory Traversal in File function

This submodule checks for directory traversal vulnerabilities in the File module.

Directory Traversal in send_download

This submodule checks for directory traversal vulnerabilities in the send_download function of a Phoenix Controller.

Directory Traversal in send_file

This submodule checks for directory traversal vulnerabilities in the send_file function.

Known Vulnerable Dependencies

An application with known vulnerabilities is more easily subjected to automated or targeted attacks.

Coherence Version Vulnerable to Privilege Escalation

For more information visit: https://github.com/advisories/GHSA-mrq8-53r4-3j5m

Plug Version Vulnerable to Arbitrary Code Execution in Cookie Serialization

For more information visit: https://github.com/advisories/GHSA-5v4m-c73v-c7gq

Ecto Version Lacks Protection Mechanism

For more information visit: https://github.com/advisories/GHSA-2xxx-fhc8-9qvq

Plug Version Vulnerable to Header Injection

For more information visit: https://github.com/advisories/GHSA-9h73-w7ch-rh73

Plug Version Vulnerable to Null Byte Injection

For more information visit: https://github.com/advisories/GHSA-2q6v-32mr-8p8x

Phoenix Version Vulnerable to Arbitrary URL Redirection

For more information visit: https://github.com/advisories/GHSA-cmfh-8f8r-fj96

Cross-Site Scripting

Cross-Site Scripting (XSS) vulnerabilities are a result of rendering untrusted input on a page without proper encoding. XSS may allow an attacker to perform actions on behalf of other users, steal session tokens, or access private data.

XSS in put_resp_content_type

If an attacker is able to set arbitrary content types for an HTTP response containing user input, the attacker is likely to be able to leverage this for cross-site scripting (XSS).

XSS in html

This submodule looks for XSS vulnerabilities in html calls from the Phoenix Controller.

XSS in raw

This submodule checks for the use of raw in templates as this can lead to XSS vulnerabilities if taking user input.

XSS in send_resp

This submodule looks for XSS vulnerabilities in the body argument of Conn.send_resp.

Mix Tasks

Sobelow is a static analysis tool for discovering vulnerabilities in Phoenix applications.