Elixir User Controlled Connection String
Description
This detector identifies vulnerabilities where user-controlled input is used to construct database connection strings in Elixir applications. When connection parameters like hostnames, usernames, or passwords come from untrusted sources, attackers can potentially redirect connections to malicious databases or extract sensitive information from connection strings.
Detection Strategy
• Scans Elixir code for function calls that establish database connections using connection string parameters
• Identifies functions that accept connection URIs through positional arguments or keyword parameters (like 'uri')
• Traces the source of connection string data to determine if it originates from user input, request parameters, or other untrusted sources
• Reports a vulnerability when a connection string contains user-controlled data that hasn't been properly validated or sanitized
Vulnerable code example
defmodule ConnectionStringDemo do
import Plug.Conn
def unsafe_redis_connection(conn, _opts) do
host = conn.params["host"]
# VULNERABLE: credentials sent to attacker-controlled host
Redix.start_link("redis://user:pass@#{host}:6379/0")...✅ Secure code example
defmodule ConnectionStringDemo do
import Plug.Conn
def unsafe_redis_connection(conn, _opts) do
host = conn.params["host"]
# Validate host against allowlist to prevent credential leakage
allowed_hosts = ["cache-1.internal", "cache-2.internal"]...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.