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

Prevent atom DoS vulnerabilities by avoiding String.to_atom/1 #41

Open
5 tasks
Kavignon opened this issue Dec 8, 2024 · 0 comments
Open
5 tasks

Prevent atom DoS vulnerabilities by avoiding String.to_atom/1 #41

Kavignon opened this issue Dec 8, 2024 · 0 comments
Assignees
Labels
security Preventing misuse or vulnerabilities in software
Milestone

Comments

@Kavignon
Copy link
Contributor

Kavignon commented Dec 8, 2024

Description

Atoms are not garbage-collected, which can lead to memory exhaustion if many unique atoms are created dynamically.
It poses a security risk, as an attacker could exploit this to crash the application via a denial-of-service (DoS) attack.
To mitigate this, we should enforce safer practices in the template and educate developers on the risks and alternatives. The String.to_atom/1 function can lead to atom DoS vulnerabilities when used with untrusted or dynamic input, as atoms are not garbage-collected and can exhaust the BEAM's atom table.

For more information, see the Paraxial.io blog: Atom DoS: Exploiting the BEAM's Atom Table.

Tasks

  • Configure credo to warn developers about String.to_atom/1.
  • Add a CI step to check for occurrences of String.to_atom/1
  • Find a way to propose using String.to_existing_atom/1 instead of String.to_atom/1.
  • The blog suggests using a predefined map or ETS for safe string-to-atom conversions. Incorporate this as a utility in the template.
  • Document the risks and alternatives in the README
@Kavignon Kavignon added the security Preventing misuse or vulnerabilities in software label Dec 8, 2024
@Kavignon Kavignon added this to the Initial Release Candidate milestone Dec 8, 2024
@Kavignon Kavignon self-assigned this Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security Preventing misuse or vulnerabilities in software
Projects
None yet
Development

No branches or pull requests

1 participant