You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a possible vulnerability in clients that do not check the length of bytes before encoding the 4 length bytes in the postgres binary protocol.
This way, when a user sends data > 2^32, the 4 length bytes will overflow and allow an attacker to smuggle an extra message.
This extra message can be any valid postgres statement, and may result in serious security issues.
I checked the Postgrex code and it looks like the vulnerability might be here as well:
I found this in /messages.ex
def encode_msg(msg) do
{first, data} = encode(msg)
size = IO.iodata_length(data) + 4
if first do
[first, <<size::int32()>>, data]
else
[<<size::int32()>>, data]
end
end
<size:signed-32> will overflow, but the data is not trimmed.
Expected behavior
I would expect Postgrex to raise an exception.
The text was updated successfully, but these errors were encountered:
Elixir version
Any
Database and Version
Any
Postgrex Version
Any
Current behavior
Referencing this research:
https://www.youtube.com/watch?v=Tfg1B8u1yvE
There is a possible vulnerability in clients that do not check the length of bytes before encoding the 4 length bytes in the postgres binary protocol.
This way, when a user sends data > 2^32, the 4 length bytes will overflow and allow an attacker to smuggle an extra message.
This extra message can be any valid postgres statement, and may result in serious security issues.
I checked the Postgrex code and it looks like the vulnerability might be here as well:
I found this in /messages.ex
<size:signed-32> will overflow, but the data is not trimmed.
Expected behavior
I would expect Postgrex to raise an exception.
The text was updated successfully, but these errors were encountered: