File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 157157 { Credo.Check.Warning.SpecWithStruct , [ ] } ,
158158 { Credo.Check.Warning.StructFieldAmount , [ ] } ,
159159 { Credo.Check.Warning.UnsafeExec , [ ] } ,
160+ { Credo.Check.Warning.UnsafeToAtom , [ ] } ,
160161 { Credo.Check.Warning.UnusedEnumOperation , [ ] } ,
161162 { Credo.Check.Warning.UnusedFileOperation , [ ] } ,
162163 { Credo.Check.Warning.UnusedKeywordOperation , [ ] } ,
213214 { Credo.Check.Warning.LazyLogging , [ ] } ,
214215 { Credo.Check.Warning.LeakyEnvironment , [ ] } ,
215216 { Credo.Check.Warning.MapGetUnsafePass , [ ] } ,
216- { Credo.Check.Warning.MixEnv , [ ] } ,
217- { Credo.Check.Warning.UnsafeToAtom , [ ] }
217+ { Credo.Check.Warning.MixEnv , [ ] }
218218
219219 # {Credo.Check.Refactor.MapInto, []},
220220
Original file line number Diff line number Diff line change @@ -3,11 +3,16 @@ defmodule Credo.Check.Warning.UnsafeToAtom do
33 id: "EX5016" ,
44 base_priority: :high ,
55 category: :warning ,
6- tags: [ :controversial ] ,
76 explanations: [
87 check: """
9- Creating atoms from unknown or external sources dynamically is a potentially
10- unsafe operation because atoms are not garbage-collected by the runtime.
8+ Creating atoms from unknown or external input is a security risk, not just a
9+ style preference.
10+
11+ Atoms are not garbage-collected by the runtime and the number of atoms a node
12+ can hold is capped (1_048_576 by default). Any code path that turns
13+ attacker-controlled input into atoms can therefore exhaust the atom table and
14+ crash the entire VM. That is a denial-of-service vulnerability, and in a
15+ web-facing application it is a CVE waiting to happen.
1116
1217 Creating an atom from a string or charlist should be done by using
1318
@@ -33,6 +38,9 @@ defmodule Credo.Check.Warning.UnsafeToAtom do
3338
3439 Jason.decode(str)
3540
41+ For more on atom exhaustion as an attack vector, see:
42+
43+ https://erlef.org/blog/security/atom-exhaustion
3644 """
3745 ]
3846
You can’t perform that action at this time.
0 commit comments