A flaw in the `mod sql` module occurs due to insufficient protection of the SQL query structure. Remote attackers can execute arbitrary code by providing a specially crafted `username` in scenarios where `USER` requests are logged using expansions such as `%U`, provided the SQL backend supports commands like `COPY TO PROGRAM`. This issue can also lead to authentication bypass.