Skip to content

Encoding of IO lists is unsafe (missing escaping) #182

@maximedenes

Description

@maximedenes

Queries executed with IO list arguments are not correctly escaped, leading to possible code injections:

emysql:execute(mypool, <<"SELECT * FROM foo WHERE id = ?">>, [["te'st"]]).

I believe the culprit is in emysql_conn.erl:

encode(Val, binary) when is_list(Val) ->
    list_to_binary(quote(Val));

if Val is an iolist, quote will have no effect and list_to_binary will happily construct an unescaped (binary) string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions