Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential memory leak #68

Closed
e-nikolov opened this issue Feb 6, 2020 · 5 comments
Closed

Potential memory leak #68

e-nikolov opened this issue Feb 6, 2020 · 5 comments

Comments

@e-nikolov
Copy link

I'm new to elixir, so I'm not sure if this is true, but since atoms are never cleared from memory, I've heard they are a potential attack vector if user input gets converted to atoms. In the code bellow, the http method gets converted to an atom, and since a user can define an arbitrary method, would this not be an issue?

lib/reverse_proxy_plug.ex

defp prepare_request(conn, options) do
    method = conn.method |> String.downcase() |> String.to_atom()
    ...
end
@j-deng
Copy link
Contributor

j-deng commented Feb 28, 2020

@e-nikolov HI, for the http methods to atom, it won't be an attack, because there are only a few methods such as get, post, put, delete and so on, so there are only a few atoms will be created. There is just one atom will be in VM no matter how many times it's created.

@e-nikolov
Copy link
Author

Those methods are the most used ones, but using curl for example, you can specify any arbitrary string as an http method.

@j-deng
Copy link
Contributor

j-deng commented Feb 28, 2020

@e-nikolov 👍 got it, That's could be a problem. maybe we can use String.to_existing_atom, and pre-generate the method atoms we need.

@j-deng
Copy link
Contributor

j-deng commented Feb 28, 2020

@e-nikolov i gotta make some other changes, so by the time maybe do a fix try in here, please review
master...j-deng:master

@mwhitworth
Copy link
Collaborator

I've merged #105 - thanks @j-deng!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants