deepscan-cli 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/NOTICE +5 -0
  2. package/README.md +174 -59
  3. package/dist/bin/deepscan.js +189 -71
  4. package/dist/bin/deepscan.js.map +1 -1
  5. package/dist/{chunk-OSYJXVNF.js → chunk-KITQQYNW.js} +5071 -596
  6. package/dist/chunk-KITQQYNW.js.map +1 -0
  7. package/dist/index.d.ts +61 -5
  8. package/dist/index.js +13 -3
  9. package/package.json +23 -5
  10. package/rules/built-in/default-config.yml +28 -3
  11. package/rules/built-in/operations.yml +287 -0
  12. package/rules/built-in/security.yml +12 -6
  13. package/dist/chunk-OSYJXVNF.js.map +0 -1
  14. package/rules/built-in/converted-semgrep.yml +0 -37
  15. package/rules/built-in/semgrep-apex.yml +0 -336
  16. package/rules/built-in/semgrep-bash.yml +0 -362
  17. package/rules/built-in/semgrep-c.yml +0 -429
  18. package/rules/built-in/semgrep-clojure.yml +0 -166
  19. package/rules/built-in/semgrep-csharp.yml +0 -1260
  20. package/rules/built-in/semgrep-dart.yml +0 -21
  21. package/rules/built-in/semgrep-dockerfile.yml +0 -874
  22. package/rules/built-in/semgrep-elixir.yml +0 -146
  23. package/rules/built-in/semgrep-generic.yml +0 -2945
  24. package/rules/built-in/semgrep-go.yml +0 -2898
  25. package/rules/built-in/semgrep-hcl.yml +0 -8181
  26. package/rules/built-in/semgrep-html.yml +0 -94
  27. package/rules/built-in/semgrep-java.yml +0 -4219
  28. package/rules/built-in/semgrep-javascript.yml +0 -6243
  29. package/rules/built-in/semgrep-json.yml +0 -360
  30. package/rules/built-in/semgrep-kotlin.yml +0 -540
  31. package/rules/built-in/semgrep-lua.yml +0 -46
  32. package/rules/built-in/semgrep-ocaml.yml +0 -773
  33. package/rules/built-in/semgrep-php.yml +0 -1638
  34. package/rules/built-in/semgrep-python.yml +0 -11240
  35. package/rules/built-in/semgrep-regex.yml +0 -6444
  36. package/rules/built-in/semgrep-ruby.yml +0 -2687
  37. package/rules/built-in/semgrep-rust.yml +0 -278
  38. package/rules/built-in/semgrep-scala.yml +0 -807
  39. package/rules/built-in/semgrep-sh.yml +0 -46
  40. package/rules/built-in/semgrep-solidity.yml +0 -1046
  41. package/rules/built-in/semgrep-swift.yml +0 -200
  42. package/rules/built-in/semgrep-terraform.yml +0 -147
  43. package/rules/built-in/semgrep-typescript.yml +0 -6212
  44. package/rules/built-in/semgrep-xml.yml +0 -31
  45. package/rules/built-in/semgrep-yaml.yml +0 -2785
  46. package/rules/examples/custom-api-security.yml +0 -66
@@ -1,874 +0,0 @@
1
- rules:
2
- - id: dockerfile-pip-extra-index-url
3
- name: dockerfile-pip-extra-index-url
4
- description: >-
5
- When `--extra-index-url` is used in a `pip install` command, this is usually meant to install a package from a
6
- package index other than the public one. However, if a package is added with the same name to the public PyPi
7
- repository, and if the version number is high enough, this package will be installed when building this docker
8
- image. This package may be a malicious dependency. Such an attack is called a dependency confusion attack. If
9
- using a private package index, prefer to use `--index-url` if possible.
10
- category: file-ops
11
- severity: low
12
- confidence: medium
13
- languages:
14
- - dockerfile
15
- patterns:
16
- - pattern: |
17
- RUN ... $PIP install ... --extra-index-url ...
18
- message: >-
19
- When `--extra-index-url` is used in a `pip install` command, this is usually meant to install a package from
20
- a package index other than the public one. However, if a package is added with the same name to the public
21
- PyPi repository, and if the version number is high enough, this package will be installed when building this
22
- docker image. This package may be a malicious dependency. Such an attack is called a dependency confusion
23
- attack. If using a private package index, prefer to use `--index-url` if possible.
24
- cwe:
25
- - CWE-427
26
- owasp: []
27
- references:
28
- - https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-extra-index-url
29
- - https://github.com/semgrep/semgrep-rules/issues/3032
30
- tags:
31
- - docker
32
- - id: dockerfile-source-not-pinned
33
- name: dockerfile-source-not-pinned
34
- description: >-
35
- To ensure reproducible builds, pin Dockerfile `FROM` commands to a specific hash. You can find the hash by running
36
- `docker pull $IMAGE` and then specify it with `$IMAGE:$VERSION@sha256:<hash goes here>`
37
- category: injection
38
- severity: low
39
- confidence: medium
40
- languages:
41
- - dockerfile
42
- patterns:
43
- - regex: .*
44
- message: >-
45
- To ensure reproducible builds, pin Dockerfile `FROM` commands to a specific hash. You can find the hash by
46
- running `docker pull $IMAGE` and then specify it with `$IMAGE:$VERSION@sha256:<hash goes here>`
47
- cwe: []
48
- owasp: []
49
- references:
50
- - https://stackoverflow.com/a/33511811/4965
51
- tags:
52
- - docker
53
- - id: avoid-apk-upgrade
54
- name: avoid-apk-upgrade
55
- description: >-
56
- Packages in base images should be up-to-date, removing the need for 'apk upgrade'. If packages are out-of-date,
57
- consider contacting the base image maintainer.
58
- category: security
59
- severity: low
60
- confidence: medium
61
- languages:
62
- - dockerfile
63
- patterns:
64
- - pattern: RUN ... apk upgrade ...
65
- message: >-
66
- Packages in base images should be up-to-date, removing the need for 'apk upgrade'. If packages are
67
- out-of-date, consider contacting the base image maintainer.
68
- cwe: []
69
- owasp: []
70
- references:
71
- - https://github.com/hadolint/hadolint/wiki/DL3017
72
- tags:
73
- - dockerfile
74
- - id: avoid-apt-get-upgrade
75
- name: avoid-apt-get-upgrade
76
- description: >-
77
- Packages in base containers should be up-to-date, removing the need to upgrade or dist-upgrade. If a package is
78
- out of date, contact the maintainers.
79
- category: security
80
- severity: medium
81
- confidence: medium
82
- languages:
83
- - dockerfile
84
- patterns:
85
- - pattern: RUN ... apt-get upgrade ...
86
- message: >-
87
- Packages in base containers should be up-to-date, removing the need to upgrade or dist-upgrade. If a package
88
- is out of date, contact the maintainers.
89
- - pattern: RUN ... apt-get dist-upgrade ...
90
- message: >-
91
- Packages in base containers should be up-to-date, removing the need to upgrade or dist-upgrade. If a package
92
- is out of date, contact the maintainers.
93
- cwe: []
94
- owasp: []
95
- references:
96
- - https://github.com/hadolint/hadolint/wiki/DL3005
97
- tags:
98
- - dockerfile
99
- - id: avoid-dnf-update
100
- name: avoid-dnf-update
101
- description: >-
102
- Packages in base images should be up-to-date, removing the need for 'dnf update'. If packages are out-of-date,
103
- consider contacting the base image maintainer.
104
- category: security
105
- severity: low
106
- confidence: medium
107
- languages:
108
- - dockerfile
109
- patterns:
110
- - pattern: dnf update
111
- message: >-
112
- Packages in base images should be up-to-date, removing the need for 'dnf update'. If packages are out-of-date,
113
- consider contacting the base image maintainer.
114
- cwe: []
115
- owasp: []
116
- references:
117
- - https://github.com/hadolint/hadolint/wiki/DL3039
118
- tags:
119
- - dockerfile
120
- - id: avoid-latest-version
121
- name: avoid-latest-version
122
- description: >-
123
- Images should be tagged with an explicit version to produce deterministic container images. The 'latest' tag may
124
- change the base container without warning.
125
- category: security
126
- severity: medium
127
- confidence: medium
128
- languages:
129
- - dockerfile
130
- patterns:
131
- - pattern: FROM $FROM:latest
132
- message: >-
133
- Images should be tagged with an explicit version to produce deterministic container images. The 'latest' tag
134
- may change the base container without warning.
135
- cwe: []
136
- owasp: []
137
- references:
138
- - https://github.com/hadolint/hadolint/wiki/DL3007
139
- tags:
140
- - dockerfile
141
- - id: avoid-platform-with-from
142
- name: avoid-platform-with-from
143
- description: >-
144
- Using '--platform' with FROM restricts the image to build on a single platform. Further, this must be the same as
145
- the build platform. If you intended to specify the target platform, use the utility 'docker buildx --platform='
146
- instead.
147
- category: security
148
- severity: low
149
- confidence: medium
150
- languages:
151
- - dockerfile
152
- patterns:
153
- - pattern: FROM --platform=$PLATFORM $IMAGE
154
- message: >-
155
- Using '--platform' with FROM restricts the image to build on a single platform. Further, this must be the same
156
- as the build platform. If you intended to specify the target platform, use the utility 'docker buildx
157
- --platform=' instead.
158
- cwe: []
159
- owasp: []
160
- references:
161
- - https://github.com/hadolint/hadolint/wiki/DL3029
162
- - https://docs.docker.com/buildx/working-with-buildx/
163
- tags:
164
- - dockerfile
165
- - id: avoid-yum-update
166
- name: avoid-yum-update
167
- description: >-
168
- Packages in base images should be up-to-date, removing the need for 'yum update'. If packages are out-of-date,
169
- consider contacting the base image maintainer.
170
- category: security
171
- severity: low
172
- confidence: medium
173
- languages:
174
- - dockerfile
175
- patterns:
176
- - pattern: yum update
177
- message: >-
178
- Packages in base images should be up-to-date, removing the need for 'yum update'. If packages are out-of-date,
179
- consider contacting the base image maintainer.
180
- cwe: []
181
- owasp: []
182
- references:
183
- - https://github.com/hadolint/hadolint/wiki/DL3031
184
- tags:
185
- - dockerfile
186
- - id: avoid-zypper-update
187
- name: avoid-zypper-update
188
- description: >-
189
- Packages in base images should be up-to-date, removing the need for 'zypper update'. If packages are out-of-date,
190
- consider contacting the base image maintainer.
191
- category: security
192
- severity: low
193
- confidence: medium
194
- languages:
195
- - dockerfile
196
- patterns:
197
- - pattern: zypper update ...
198
- message: >-
199
- Packages in base images should be up-to-date, removing the need for 'zypper update'. If packages are
200
- out-of-date, consider contacting the base image maintainer.
201
- cwe: []
202
- owasp: []
203
- references:
204
- - https://github.com/hadolint/hadolint/wiki/DL3035
205
- tags:
206
- - dockerfile
207
- - id: maintainer-is-deprecated
208
- name: maintainer-is-deprecated
209
- description: MAINTAINER has been deprecated.
210
- category: security
211
- severity: low
212
- confidence: medium
213
- languages:
214
- - dockerfile
215
- patterns:
216
- - pattern: MAINTAINER $NAME
217
- message: MAINTAINER has been deprecated.
218
- cwe: []
219
- owasp: []
220
- references:
221
- - https://github.com/hadolint/hadolint/wiki/DL4000
222
- tags:
223
- - dockerfile
224
- - id: missing-apk-no-cache
225
- name: missing-apk-no-cache
226
- description: >-
227
- This apk command is missing '--no-cache'. This forces apk to use a package index instead of a local package cache,
228
- removing the need for '--update' and the deletion of '/var/cache/apk/*'. Add '--no-cache' to your apk command.
229
- category: security
230
- severity: low
231
- confidence: medium
232
- languages:
233
- - dockerfile
234
- patterns:
235
- - pattern: |
236
- RUN apk $COMMAND ...
237
- message: >-
238
- This apk command is missing '--no-cache'. This forces apk to use a package index instead of a local package
239
- cache, removing the need for '--update' and the deletion of '/var/cache/apk/*'. Add '--no-cache' to your apk
240
- command.
241
- cwe: []
242
- owasp: []
243
- references:
244
- - https://github.com/hadolint/hadolint/wiki/DL3019
245
- tags:
246
- - dockerfile
247
- - id: missing-dnf-assume-yes-switch
248
- name: missing-dnf-assume-yes-switch
249
- description: >-
250
- This 'dnf install' is missing the '-y' switch. This might stall builds because it requires human intervention. Add
251
- the '-y' switch.
252
- category: security
253
- severity: medium
254
- confidence: medium
255
- languages:
256
- - dockerfile
257
- patterns:
258
- - pattern: |
259
- RUN ... dnf install ...
260
- message: >-
261
- This 'dnf install' is missing the '-y' switch. This might stall builds because it requires human intervention.
262
- Add the '-y' switch.
263
- cwe: []
264
- owasp: []
265
- references:
266
- - https://github.com/hadolint/hadolint/wiki/DL3038
267
- tags:
268
- - dockerfile
269
- - id: missing-dnf-clean-all
270
- name: missing-dnf-clean-all
271
- description: >-
272
- This dnf command does not end with '&& dnf clean all'. Running 'dnf clean all' will remove cached data and reduce
273
- package size. (This must be performed in the same RUN step.)
274
- category: security
275
- severity: medium
276
- confidence: medium
277
- languages:
278
- - dockerfile
279
- patterns:
280
- - pattern: RUN ... dnf ...
281
- message: >-
282
- This dnf command does not end with '&& dnf clean all'. Running 'dnf clean all' will remove cached data and
283
- reduce package size. (This must be performed in the same RUN step.)
284
- cwe: []
285
- owasp: []
286
- references:
287
- - https://github.com/hadolint/hadolint/wiki/DL3038
288
- tags:
289
- - dockerfile
290
- - id: missing-image-version
291
- name: missing-image-version
292
- description: >-
293
- Detected docker image with no explicit version attached. Images should be tagged with an explicit version to
294
- produce deterministic container images -- attach a version when using `FROM <image>`.
295
- category: security
296
- severity: medium
297
- confidence: medium
298
- languages:
299
- - dockerfile
300
- patterns:
301
- - regex: .*
302
- message: >-
303
- Detected docker image with no explicit version attached. Images should be tagged with an explicit version to
304
- produce deterministic container images -- attach a version when using `FROM <image>`.
305
- cwe: []
306
- owasp: []
307
- references:
308
- - https://github.com/hadolint/hadolint/wiki/DL3006
309
- tags:
310
- - dockerfile
311
- - id: missing-no-install-recommends
312
- name: missing-no-install-recommends
313
- description: >-
314
- This 'apt-get install' is missing '--no-install-recommends'. This prevents unnecessary packages from being
315
- installed, thereby reducing image size. Add '--no-install-recommends'.
316
- category: security
317
- severity: low
318
- confidence: medium
319
- languages:
320
- - dockerfile
321
- patterns:
322
- - pattern: |
323
- RUN apt-get install ...
324
- message: >-
325
- This 'apt-get install' is missing '--no-install-recommends'. This prevents unnecessary packages from being
326
- installed, thereby reducing image size. Add '--no-install-recommends'.
327
- cwe: []
328
- owasp: []
329
- references:
330
- - https://github.com/hadolint/hadolint/wiki/DL3015
331
- tags:
332
- - dockerfile
333
- - id: missing-pip-no-cache-dir
334
- name: missing-pip-no-cache-dir
335
- description: >-
336
- This '$PIP install' is missing '--no-cache-dir'. This flag prevents package archives from being kept around,
337
- thereby reducing image size. Add '--no-cache-dir'.
338
- category: security
339
- severity: low
340
- confidence: medium
341
- languages:
342
- - dockerfile
343
- patterns:
344
- - regex: .*
345
- message: >-
346
- This '$PIP install' is missing '--no-cache-dir'. This flag prevents package archives from being kept around,
347
- thereby reducing image size. Add '--no-cache-dir'.
348
- cwe: []
349
- owasp: []
350
- references:
351
- - https://github.com/hadolint/hadolint/wiki/DL3042
352
- tags:
353
- - dockerfile
354
- - id: missing-yum-assume-yes-switch
355
- name: missing-yum-assume-yes-switch
356
- description: >-
357
- This 'yum install' is missing the '-y' switch. This might stall builds because it requires human intervention. Add
358
- the '-y' switch.
359
- category: security
360
- severity: medium
361
- confidence: medium
362
- languages:
363
- - dockerfile
364
- patterns:
365
- - pattern: |
366
- RUN ... yum install ...
367
- message: >-
368
- This 'yum install' is missing the '-y' switch. This might stall builds because it requires human intervention.
369
- Add the '-y' switch.
370
- cwe: []
371
- owasp: []
372
- references:
373
- - https://github.com/hadolint/hadolint/wiki/DL3030
374
- tags:
375
- - dockerfile
376
- - id: missing-zypper-clean
377
- name: missing-zypper-clean
378
- description: >-
379
- This zypper command does not end with '&& zypper clean'. Running 'zypper clean' will remove cached data and reduce
380
- package size. (This must be performed in the same RUN step.)
381
- category: security
382
- severity: medium
383
- confidence: medium
384
- languages:
385
- - dockerfile
386
- patterns:
387
- - pattern: RUN ... zypper $COMMAND ...
388
- message: >-
389
- This zypper command does not end with '&& zypper clean'. Running 'zypper clean' will remove cached data and
390
- reduce package size. (This must be performed in the same RUN step.)
391
- cwe: []
392
- owasp: []
393
- references:
394
- - https://github.com/hadolint/hadolint/wiki/DL3036
395
- tags:
396
- - dockerfile
397
- - id: nonsensical-command
398
- name: nonsensical-command
399
- description: Some commands such as `$CMD` do not make sense in a container. Do not use these.
400
- category: security
401
- severity: medium
402
- confidence: medium
403
- languages:
404
- - dockerfile
405
- patterns:
406
- - pattern: RUN $CMD ...
407
- message: Some commands such as `$CMD` do not make sense in a container. Do not use these.
408
- cwe: []
409
- owasp: []
410
- references:
411
- - https://github.com/hadolint/hadolint/wiki/DL3001
412
- tags:
413
- - dockerfile
414
- - id: prefer-apt-get
415
- name: prefer-apt-get
416
- description: '''apt-get'' is preferred as an unattended tool for stability. ''apt'' is discouraged.'
417
- category: security
418
- severity: low
419
- confidence: medium
420
- languages:
421
- - dockerfile
422
- patterns:
423
- - pattern: RUN apt ...
424
- message: '''apt-get'' is preferred as an unattended tool for stability. ''apt'' is discouraged.'
425
- cwe: []
426
- owasp: []
427
- references:
428
- - https://github.com/hadolint/hadolint/wiki/DL3027
429
- tags:
430
- - dockerfile
431
- - id: prefer-copy-over-add
432
- name: prefer-copy-over-add
433
- description: >-
434
- The ADD command will accept and include files from a URL and automatically extract archives. This potentially
435
- exposes the container to a man-in-the-middle attack or other attacks if a malicious actor can tamper with the
436
- source archive. Since ADD can have this and other unexpected side effects, the use of the more explicit COPY
437
- command is preferred.
438
- category: security
439
- severity: low
440
- confidence: medium
441
- languages:
442
- - dockerfile
443
- patterns:
444
- - pattern: |
445
- ADD $FROM $TO
446
- message: >-
447
- The ADD command will accept and include files from a URL and automatically extract archives. This potentially
448
- exposes the container to a man-in-the-middle attack or other attacks if a malicious actor can tamper with the
449
- source archive. Since ADD can have this and other unexpected side effects, the use of the more explicit COPY
450
- command is preferred.
451
- cwe: []
452
- owasp: []
453
- references:
454
- - https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
455
- tags:
456
- - dockerfile
457
- - id: prefer-json-notation
458
- name: prefer-json-notation
459
- description: Prefer JSON notation when using CMD or ENTRYPOINT. This allows signals to be passed from the OS.
460
- category: security
461
- severity: low
462
- confidence: medium
463
- languages:
464
- - dockerfile
465
- patterns:
466
- - regex: .*
467
- message: Prefer JSON notation when using CMD or ENTRYPOINT. This allows signals to be passed from the OS.
468
- cwe: []
469
- owasp: []
470
- references:
471
- - https://github.com/hadolint/hadolint/wiki/DL3025
472
- - https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#cmd
473
- tags:
474
- - dockerfile
475
- - id: remove-package-cache
476
- name: remove-package-cache
477
- description: >-
478
- The package cache was not deleted after running 'apt-get update', which increases the size of the image. Remove
479
- the package cache by appending '&& apt-get clean' at the end of apt-get command chain.
480
- category: security
481
- severity: medium
482
- confidence: medium
483
- languages:
484
- - dockerfile
485
- patterns:
486
- - pattern: RUN ... apt-get update ...
487
- message: >-
488
- The package cache was not deleted after running 'apt-get update', which increases the size of the image.
489
- Remove the package cache by appending '&& apt-get clean' at the end of apt-get command chain.
490
- - pattern: apt-get update
491
- message: >-
492
- The package cache was not deleted after running 'apt-get update', which increases the size of the image.
493
- Remove the package cache by appending '&& apt-get clean' at the end of apt-get command chain.
494
- cwe: []
495
- owasp: []
496
- references:
497
- - https://github.com/hadolint/hadolint/wiki/DL3009
498
- tags:
499
- - dockerfile
500
- - id: remove-package-lists
501
- name: remove-package-lists
502
- description: >-
503
- The package lists were not deleted after running 'apt-get update', which increases the size of the image. Remove
504
- the package lists by appending '&& rm -rf /var/lib/apt/lists/*' at the end of apt-get command chain.
505
- category: security
506
- severity: medium
507
- confidence: medium
508
- languages:
509
- - dockerfile
510
- patterns:
511
- - pattern: RUN apt-get update ...
512
- message: >-
513
- The package lists were not deleted after running 'apt-get update', which increases the size of the image.
514
- Remove the package lists by appending '&& rm -rf /var/lib/apt/lists/*' at the end of apt-get command chain.
515
- - pattern: apt-get update
516
- message: >-
517
- The package lists were not deleted after running 'apt-get update', which increases the size of the image.
518
- Remove the package lists by appending '&& rm -rf /var/lib/apt/lists/*' at the end of apt-get command chain.
519
- cwe: []
520
- owasp: []
521
- references:
522
- - https://github.com/hadolint/hadolint/wiki/DL3009
523
- tags:
524
- - dockerfile
525
- - id: set-pipefail
526
- name: set-pipefail
527
- description: >-
528
- Only the exit code from the final command in this RUN instruction will be evaluated unless 'pipefail' is set. If
529
- you want to fail the command at any stage in the pipe, set 'pipefail' by including 'SHELL ["/bin/bash", "-o",
530
- "pipefail", "-c"] before the command. If you're using alpine and don't have bash installed, communicate this
531
- explicitly with `SHELL ["/bin/ash"]`.
532
- category: security
533
- severity: medium
534
- confidence: medium
535
- languages:
536
- - dockerfile
537
- patterns:
538
- - regex: .*
539
- message: >-
540
- Only the exit code from the final command in this RUN instruction will be evaluated unless 'pipefail' is set.
541
- If you want to fail the command at any stage in the pipe, set 'pipefail' by including 'SHELL ["/bin/bash",
542
- "-o", "pipefail", "-c"] before the command. If you're using alpine and don't have bash installed, communicate
543
- this explicitly with `SHELL ["/bin/ash"]`.
544
- cwe: []
545
- owasp: []
546
- references:
547
- - https://github.com/hadolint/hadolint/wiki/DL4006
548
- tags:
549
- - dockerfile
550
- - id: use-either-wget-or-curl
551
- name: use-either-wget-or-curl
552
- description: '''wget'' and ''curl'' are similar tools. Choose one and do not install the other to decrease image size.'
553
- category: security
554
- severity: low
555
- confidence: medium
556
- languages:
557
- - dockerfile
558
- patterns:
559
- - pattern: |
560
- RUN wget ...
561
- ...
562
- RUN curl ...
563
- message: '''wget'' and ''curl'' are similar tools. Choose one and do not install the other to decrease image size.'
564
- - pattern: |
565
- RUN curl ...
566
- ...
567
- RUN wget ...
568
- message: '''wget'' and ''curl'' are similar tools. Choose one and do not install the other to decrease image size.'
569
- cwe: []
570
- owasp: []
571
- references:
572
- - https://github.com/hadolint/hadolint/wiki/DL4001
573
- tags:
574
- - dockerfile
575
- - id: use-shell-instruction
576
- name: use-shell-instruction
577
- description: Use the SHELL instruction to set the default shell instead of overwriting '/bin/sh'.
578
- category: security
579
- severity: medium
580
- confidence: medium
581
- languages:
582
- - dockerfile
583
- patterns:
584
- - pattern: |
585
- RUN ln ... $SHELL /bin/sh
586
- message: Use the SHELL instruction to set the default shell instead of overwriting '/bin/sh'.
587
- cwe: []
588
- owasp: []
589
- references:
590
- - https://github.com/hadolint/hadolint/wiki/DL4005
591
- tags:
592
- - dockerfile
593
- - id: use-workdir
594
- name: use-workdir
595
- description: >-
596
- As recommended by Docker's documentation, it is best to use 'WORKDIR' instead of 'RUN cd ...' for improved clarity
597
- and reliability. Also, 'RUN cd ...' may not work as expected in a container.
598
- category: security
599
- severity: medium
600
- confidence: medium
601
- languages:
602
- - dockerfile
603
- patterns:
604
- - regex: .*
605
- message: >-
606
- As recommended by Docker's documentation, it is best to use 'WORKDIR' instead of 'RUN cd ...' for improved
607
- clarity and reliability. Also, 'RUN cd ...' may not work as expected in a container.
608
- cwe: []
609
- owasp: []
610
- references:
611
- - https://github.com/hadolint/hadolint/wiki/DL3003
612
- tags:
613
- - dockerfile
614
- - id: invalid-port
615
- name: invalid-port
616
- description: Detected an invalid port number. Valid ports are 0 through 65535.
617
- category: security
618
- severity: high
619
- confidence: medium
620
- languages:
621
- - dockerfile
622
- patterns:
623
- - regex: .*
624
- message: Detected an invalid port number. Valid ports are 0 through 65535.
625
- cwe: []
626
- owasp: []
627
- references:
628
- - https://github.com/hadolint/hadolint/wiki/DL3011
629
- tags:
630
- - dockerfile
631
- - id: missing-assume-yes-switch
632
- name: missing-assume-yes-switch
633
- description: >-
634
- This 'apt-get install' is missing the '-y' switch. This might stall builds because it requires human intervention.
635
- Add the '-y' switch.
636
- category: security
637
- severity: medium
638
- confidence: medium
639
- languages:
640
- - dockerfile
641
- patterns:
642
- - pattern: |
643
- RUN ... apt-get install ... $MULTIFLAG ...
644
- message: >-
645
- This 'apt-get install' is missing the '-y' switch. This might stall builds because it requires human
646
- intervention. Add the '-y' switch.
647
- cwe: []
648
- owasp: []
649
- references:
650
- - https://github.com/hadolint/hadolint/wiki/DL3014
651
- tags:
652
- - dockerfile
653
- - id: multiple-entrypoint-instructions
654
- name: multiple-entrypoint-instructions
655
- description: Multiple ENTRYPOINT instructions were found. Only the last one will take effect.
656
- category: security
657
- severity: high
658
- confidence: medium
659
- languages:
660
- - dockerfile
661
- patterns:
662
- - pattern: |
663
- ENTRYPOINT ...
664
- ...
665
- $ENTRYPOINT_INSTR
666
- message: Multiple ENTRYPOINT instructions were found. Only the last one will take effect.
667
- cwe: []
668
- owasp: []
669
- references:
670
- - https://github.com/hadolint/hadolint/wiki/DL4004
671
- - >-
672
- https://kapeli.com/cheat_sheets/Dockerfile.docset/Contents/Resources/Documents/index#//dash_ref_Instructions/Entry/ENTRYPOINT/0
673
- tags:
674
- - dockerfile
675
- - id: dockerfile-dockerd-socket-mount
676
- name: dockerfile-dockerd-socket-mount
677
- description: >-
678
- The Dockerfile(image) mounts docker.sock to the container which may allow an attacker already inside of the
679
- container to escape container and execute arbitrary commands on the host machine.
680
- category: file-ops
681
- severity: high
682
- confidence: medium
683
- languages:
684
- - dockerfile
685
- - yaml
686
- patterns:
687
- - regex: .*
688
- message: >-
689
- The Dockerfile(image) mounts docker.sock to the container which may allow an attacker already inside of the
690
- container to escape container and execute arbitrary commands on the host machine.
691
- cwe:
692
- - CWE-862
693
- - CWE-269
694
- owasp: []
695
- references:
696
- - https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
697
- - https://redfoxsec.com/blog/insecure-volume-mounts-in-docker/
698
- - https://blog.quarkslab.com/why-is-exposing-the-docker-socket-a-really-bad-idea.html
699
- tags:
700
- - dockerfile
701
- - id: last-user-is-root
702
- name: last-user-is-root
703
- description: >-
704
- The last user in the container is 'root'. This is a security hazard because if an attacker gains control of the
705
- container they will have root access. Switch back to another user after running commands as 'root'.
706
- category: security
707
- severity: high
708
- confidence: medium
709
- languages:
710
- - dockerfile
711
- patterns:
712
- - pattern: USER root
713
- message: >-
714
- The last user in the container is 'root'. This is a security hazard because if an attacker gains control of
715
- the container they will have root access. Switch back to another user after running commands as 'root'.
716
- cwe:
717
- - CWE-269
718
- owasp:
719
- - A04:2021
720
- - A06:2025
721
- references:
722
- - https://github.com/hadolint/hadolint/wiki/DL3002
723
- tags:
724
- - dockerfile
725
- - id: missing-user-entrypoint
726
- name: missing-user-entrypoint
727
- description: >-
728
- By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an attacker
729
- can control a process running as root, they may have control over the container. Ensure that the last USER in a
730
- Dockerfile is a USER other than 'root'.
731
- category: security
732
- severity: high
733
- confidence: medium
734
- languages:
735
- - dockerfile
736
- patterns:
737
- - pattern: |
738
- ENTRYPOINT $...VARS
739
- message: >-
740
- By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an
741
- attacker can control a process running as root, they may have control over the container. Ensure that the last
742
- USER in a Dockerfile is a USER other than 'root'.
743
- cwe:
744
- - CWE-269
745
- owasp:
746
- - A04:2021
747
- - A06:2025
748
- references:
749
- - https://owasp.org/Top10/A04_2021-Insecure_Design
750
- tags:
751
- - dockerfile
752
- - id: missing-user
753
- name: missing-user
754
- description: >-
755
- By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an attacker
756
- can control a process running as root, they may have control over the container. Ensure that the last USER in a
757
- Dockerfile is a USER other than 'root'.
758
- category: security
759
- severity: high
760
- confidence: medium
761
- languages:
762
- - dockerfile
763
- patterns:
764
- - pattern: |
765
- CMD $...VARS
766
- message: >-
767
- By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an
768
- attacker can control a process running as root, they may have control over the container. Ensure that the last
769
- USER in a Dockerfile is a USER other than 'root'.
770
- cwe:
771
- - CWE-250
772
- owasp:
773
- - A04:2021
774
- - A06:2025
775
- references:
776
- - https://owasp.org/Top10/A04_2021-Insecure_Design
777
- tags:
778
- - dockerfile
779
- - id: no-sudo-in-dockerfile
780
- name: no-sudo-in-dockerfile
781
- description: >-
782
- Avoid using sudo in Dockerfiles. Running processes as a non-root user can help reduce the potential impact of
783
- configuration errors and security vulnerabilities.
784
- category: file-ops
785
- severity: medium
786
- confidence: medium
787
- languages:
788
- - dockerfile
789
- patterns:
790
- - pattern: |
791
- RUN sudo ...
792
- message: >-
793
- Avoid using sudo in Dockerfiles. Running processes as a non-root user can help reduce the potential impact of
794
- configuration errors and security vulnerabilities.
795
- cwe:
796
- - CWE-250
797
- owasp:
798
- - A05:2021
799
- - A02:2025
800
- references:
801
- - https://cwe.mitre.org/data/definitions/250.html
802
- - https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
803
- tags:
804
- - dockerfile
805
- - id: secret-in-build-arg
806
- name: secret-in-build-arg
807
- description: >-
808
- Docker build time arguments are not suited for secrets, because the argument values are saved with the image.
809
- Running `docker image history` on the image will show information on how the image was built, including arguments.
810
- If these contain plain text secrets, anyone with access to the docker image can access those secrets and exploit
811
- them.
812
- category: secrets
813
- severity: medium
814
- confidence: medium
815
- languages:
816
- - dockerfile
817
- patterns:
818
- - regex: .*
819
- message: >-
820
- Docker build time arguments are not suited for secrets, because the argument values are saved with the image.
821
- Running `docker image history` on the image will show information on how the image was built, including
822
- arguments. If these contain plain text secrets, anyone with access to the docker image can access those
823
- secrets and exploit them.
824
- cwe:
825
- - CWE-538
826
- owasp:
827
- - A01:2021
828
- - A01:2025
829
- references:
830
- - https://cwe.mitre.org/data/definitions/538.html
831
- - https://docs.docker.com/engine/reference/builder/#arg
832
- tags:
833
- - dockerfile
834
- - id: multiple-cmd-instructions
835
- name: multiple-cmd-instructions
836
- description: Multiple CMD instructions were found. Only the last one will take effect.
837
- category: security
838
- severity: high
839
- confidence: medium
840
- languages:
841
- - dockerfile
842
- patterns:
843
- - regex: .*
844
- message: Multiple CMD instructions were found. Only the last one will take effect.
845
- cwe: []
846
- owasp: []
847
- references:
848
- - https://github.com/hadolint/hadolint/wiki/DL4003
849
- - >-
850
- https://kapeli.com/cheat_sheets/Dockerfile.docset/Contents/Resources/Documents/index#//dash_ref_Instructions/Entry/CMD/0
851
- tags:
852
- - dockerfile
853
- - id: missing-zypper-no-confirm-switch
854
- name: missing-zypper-no-confirm-switch
855
- description: >-
856
- This 'zypper install' is missing the '-y' switch. This might stall builds because it requires human intervention.
857
- Add the '-y' switch.
858
- category: security
859
- severity: medium
860
- confidence: medium
861
- languages:
862
- - dockerfile
863
- patterns:
864
- - pattern: |
865
- RUN ... zypper install ...
866
- message: >-
867
- This 'zypper install' is missing the '-y' switch. This might stall builds because it requires human
868
- intervention. Add the '-y' switch.
869
- cwe: []
870
- owasp: []
871
- references:
872
- - https://github.com/hadolint/hadolint/wiki/DL3034
873
- tags:
874
- - dockerfile