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,2898 +0,0 @@
1
- rules:
2
- - id: anthropic-hardcoded-api-key-go
3
- name: anthropic-hardcoded-api-key-go
4
- description: Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
5
- category: secrets
6
- severity: high
7
- confidence: medium
8
- languages:
9
- - go
10
- patterns:
11
- - pattern: option.WithAPIKey("$KEY")
12
- message: Anthropic API key is hardcoded in source code. Use environment variables or a secrets manager instead.
13
- cwe:
14
- - CWE-798
15
- owasp: []
16
- references:
17
- - https://docs.anthropic.com/en/docs/initial-setup
18
- tags:
19
- - anthropic
20
- - id: gemini-hardcoded-api-key-go
21
- name: gemini-hardcoded-api-key-go
22
- description: Google Gemini API key is hardcoded in source code. Use environment variables or a secrets manager instead.
23
- category: secrets
24
- severity: high
25
- confidence: medium
26
- languages:
27
- - go
28
- patterns:
29
- - pattern: option.WithAPIKey("$KEY")
30
- message: Google Gemini API key is hardcoded in source code. Use environment variables or a secrets manager instead.
31
- cwe:
32
- - CWE-798
33
- owasp: []
34
- references:
35
- - https://ai.google.dev/gemini-api/docs/api-key
36
- tags:
37
- - gemini
38
- - google
39
- - id: llm-api-key-in-source-go
40
- name: llm-api-key-in-source-go
41
- description: >-
42
- AI/LLM API key found hardcoded in source code. Detected key prefix matches a known AI provider (OpenAI, Anthropic,
43
- Google, Hugging Face). Use environment variables or a secrets manager instead.
44
- category: injection
45
- severity: high
46
- confidence: medium
47
- languages:
48
- - go
49
- patterns:
50
- - regex: .*
51
- message: >-
52
- AI/LLM API key found hardcoded in source code. Detected key prefix matches a known AI provider (OpenAI,
53
- Anthropic, Google, Hugging Face). Use environment variables or a secrets manager instead.
54
- cwe:
55
- - CWE-798
56
- owasp: []
57
- references:
58
- - https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/
59
- tags:
60
- - openai
61
- - anthropic
62
- - google
63
- - huggingface
64
- - id: openai-hardcoded-api-key-go
65
- name: openai-hardcoded-api-key-go
66
- description: OpenAI API key is hardcoded in source code. Use environment variables or a secrets manager instead.
67
- category: secrets
68
- severity: high
69
- confidence: medium
70
- languages:
71
- - go
72
- patterns:
73
- - pattern: openai.NewClient("$KEY")
74
- message: OpenAI API key is hardcoded in source code. Use environment variables or a secrets manager instead.
75
- cwe:
76
- - CWE-798
77
- owasp: []
78
- references:
79
- - https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
80
- tags:
81
- - openai
82
- - id: detect-gemini
83
- name: detect-gemini
84
- description: 'Possibly found usage of AI: Gemini'
85
- category: security
86
- severity: low
87
- confidence: medium
88
- languages:
89
- - go
90
- patterns:
91
- - pattern: import "github.com/google/generative-ai-go"
92
- message: 'Possibly found usage of AI: Gemini'
93
- - pattern: genai.NewClient(...)
94
- message: 'Possibly found usage of AI: Gemini'
95
- cwe: []
96
- owasp: []
97
- references:
98
- - https://semgrep.dev/blog/2024/detecting-shadow-ai
99
- tags:
100
- - genAI
101
- - LLMs
102
- - id: detect-openai
103
- name: detect-openai
104
- description: 'Possibly found usage of AI: OpenAI'
105
- category: security
106
- severity: low
107
- confidence: medium
108
- languages:
109
- - go
110
- patterns:
111
- - pattern: import "github.com/sashabaranov/go-openai"
112
- message: 'Possibly found usage of AI: OpenAI'
113
- - pattern: gogpt.NewClient(...)
114
- message: 'Possibly found usage of AI: OpenAI'
115
- cwe: []
116
- owasp: []
117
- references:
118
- - https://semgrep.dev/blog/2024/detecting-shadow-ai
119
- tags:
120
- - genAI
121
- - LLMs
122
- - id: contains-bidirectional-characters
123
- name: contains-bidirectional-characters
124
- description: >-
125
- This code contains bidirectional (bidi) characters. While this is useful for support of right-to-left languages
126
- such as Arabic or Hebrew, it can also be used to trick language parsers into executing code in a manner that is
127
- different from how it is displayed in code editing and review tools. If this is not what you were expecting,
128
- please review this code in an editor that can reveal hidden Unicode characters.
129
- category: security
130
- severity: medium
131
- confidence: medium
132
- languages:
133
- - bash
134
- - c
135
- - csharp
136
- - go
137
- - java
138
- - javascript
139
- - json
140
- - kotlin
141
- - lua
142
- - ocaml
143
- - php
144
- - python
145
- - ruby
146
- - rust
147
- - scala
148
- - sh
149
- - typescript
150
- - yaml
151
- patterns:
152
- - regex: .*
153
- message: >-
154
- This code contains bidirectional (bidi) characters. While this is useful for support of right-to-left
155
- languages such as Arabic or Hebrew, it can also be used to trick language parsers into executing code in a
156
- manner that is different from how it is displayed in code editing and review tools. If this is not what you
157
- were expecting, please review this code in an editor that can reveal hidden Unicode characters.
158
- cwe:
159
- - CWE-94
160
- owasp:
161
- - A03:2021
162
- - A05:2025
163
- references:
164
- - https://trojansource.codes/
165
- tags:
166
- - unicode
167
- - id: database-sqli
168
- name: database-sqli
169
- description: >-
170
- Detected SQL statement that is tainted by `$EVENT` object. This could lead to SQL injection if the variable is
171
- user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
172
- prepared statements instead. You can use prepared statements with the 'Prepare' and 'PrepareContext' calls.
173
- category: injection
174
- severity: medium
175
- confidence: medium
176
- languages:
177
- - go
178
- patterns:
179
- - regex: .*
180
- message: >-
181
- Detected SQL statement that is tainted by `$EVENT` object. This could lead to SQL injection if the variable is
182
- user-controlled and not properly sanitized. In order to prevent SQL injection, use parameterized queries or
183
- prepared statements instead. You can use prepared statements with the 'Prepare' and 'PrepareContext' calls.
184
- cwe:
185
- - CWE-89
186
- owasp:
187
- - A01:2017
188
- - A03:2021
189
- - A05:2025
190
- references:
191
- - https://pkg.go.dev/database/sql#DB.Query
192
- tags:
193
- - aws-lambda
194
- - database
195
- - sql
196
- - id: tainted-sql-string
197
- name: tainted-sql-string
198
- description: >-
199
- Detected user input used to manually construct a SQL string. This is usually bad practice because manual
200
- construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or
201
- modify contents of the database. Instead, use a parameterized query which is available by default in most database
202
- engines. Alternatively, consider using an object-relational mapper (ORM) such as Sequelize which will protect your
203
- queries.
204
- category: injection
205
- severity: high
206
- confidence: medium
207
- languages:
208
- - go
209
- patterns:
210
- - regex: .*
211
- message: >-
212
- Detected user input used to manually construct a SQL string. This is usually bad practice because manual
213
- construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or
214
- modify contents of the database. Instead, use a parameterized query which is available by default in most
215
- database engines. Alternatively, consider using an object-relational mapper (ORM) such as Sequelize which will
216
- protect your queries.
217
- cwe:
218
- - CWE-89
219
- owasp:
220
- - A01:2017
221
- - A03:2021
222
- - A05:2025
223
- references:
224
- - https://owasp.org/www-community/attacks/SQL_Injection
225
- tags:
226
- - aws-lambda
227
- - id: handler-assignment-from-multiple-sources
228
- name: handler-assignment-from-multiple-sources
229
- description: >-
230
- Variable $VAR is assigned from two different sources: '$Y' and '$R'. Make sure this is intended, as this could
231
- cause logic bugs if they are treated as they are the same object.
232
- category: injection
233
- severity: medium
234
- confidence: medium
235
- languages:
236
- - go
237
- patterns:
238
- - regex: .*
239
- message: >-
240
- Variable $VAR is assigned from two different sources: '$Y' and '$R'. Make sure this is intended, as this could
241
- cause logic bugs if they are treated as they are the same object.
242
- cwe:
243
- - CWE-289
244
- owasp: []
245
- references:
246
- - https://cwe.mitre.org/data/definitions/289.html
247
- tags:
248
- - gorilla
249
- - id: session-cookie-missing-httponly
250
- name: session-cookie-missing-httponly
251
- description: >-
252
- A session cookie was detected without setting the 'HttpOnly' flag. The 'HttpOnly' flag for cookies instructs the
253
- browser to forbid client-side scripts from reading the cookie which mitigates XSS attacks. Set the 'HttpOnly' flag
254
- by setting 'HttpOnly' to 'true' in the Options struct.
255
- category: auth
256
- severity: medium
257
- confidence: medium
258
- languages:
259
- - go
260
- patterns:
261
- - pattern: |
262
- &sessions.Options{
263
- ...,
264
- }
265
- message: >-
266
- A session cookie was detected without setting the 'HttpOnly' flag. The 'HttpOnly' flag for cookies instructs
267
- the browser to forbid client-side scripts from reading the cookie which mitigates XSS attacks. Set the
268
- 'HttpOnly' flag by setting 'HttpOnly' to 'true' in the Options struct.
269
- cwe:
270
- - CWE-1004
271
- owasp:
272
- - A05:2021
273
- - A02:2025
274
- references:
275
- - https://github.com/0c34/govwa/blob/139693e56406b5684d2a6ae22c0af90717e149b8/user/session/session.go#L69
276
- tags:
277
- - gorilla
278
- - id: session-cookie-missing-secure
279
- name: session-cookie-missing-secure
280
- description: >-
281
- A session cookie was detected without setting the 'Secure' flag. The 'secure' flag for cookies prevents the client
282
- from transmitting the cookie over insecure channels such as HTTP. Set the 'Secure' flag by setting 'Secure' to
283
- 'true' in the Options struct.
284
- category: auth
285
- severity: medium
286
- confidence: medium
287
- languages:
288
- - go
289
- patterns:
290
- - pattern: |
291
- &sessions.Options{
292
- ...,
293
- }
294
- message: >-
295
- A session cookie was detected without setting the 'Secure' flag. The 'secure' flag for cookies prevents the
296
- client from transmitting the cookie over insecure channels such as HTTP. Set the 'Secure' flag by setting
297
- 'Secure' to 'true' in the Options struct.
298
- cwe:
299
- - CWE-614
300
- owasp:
301
- - A05:2021
302
- - A02:2025
303
- references:
304
- - https://github.com/0c34/govwa/blob/139693e56406b5684d2a6ae22c0af90717e149b8/user/session/session.go#L69
305
- tags:
306
- - gorilla
307
- - id: session-cookie-samesitenone
308
- name: session-cookie-samesitenone
309
- description: >-
310
- Found SameSiteNoneMode setting in Gorilla session options. Consider setting SameSite to Lax, Strict or Default for
311
- enhanced security.
312
- category: auth
313
- severity: medium
314
- confidence: medium
315
- languages:
316
- - go
317
- patterns:
318
- - pattern: |
319
- &sessions.Options{
320
- ...,
321
- }
322
- message: >-
323
- Found SameSiteNoneMode setting in Gorilla session options. Consider setting SameSite to Lax, Strict or Default
324
- for enhanced security.
325
- cwe:
326
- - CWE-1275
327
- owasp:
328
- - A05:2021
329
- - A02:2025
330
- references:
331
- - https://pkg.go.dev/github.com/gorilla/sessions#Options
332
- tags:
333
- - gorilla
334
- - id: websocket-missing-origin-check
335
- name: websocket-missing-origin-check
336
- description: >-
337
- The Origin header in the HTTP WebSocket handshake is used to guarantee that the connection accepted by the
338
- WebSocket is from a trusted origin domain. Failure to enforce can lead to Cross Site Request Forgery (CSRF). As
339
- per "gorilla/websocket" documentation: "A CheckOrigin function should carefully validate the request origin to
340
- prevent cross-site request forgery."
341
- category: security
342
- severity: medium
343
- confidence: medium
344
- languages:
345
- - go
346
- patterns:
347
- - regex: .*
348
- message: >-
349
- The Origin header in the HTTP WebSocket handshake is used to guarantee that the connection accepted by the
350
- WebSocket is from a trusted origin domain. Failure to enforce can lead to Cross Site Request Forgery (CSRF).
351
- As per "gorilla/websocket" documentation: "A CheckOrigin function should carefully validate the request origin
352
- to prevent cross-site request forgery."
353
- cwe:
354
- - CWE-352
355
- owasp:
356
- - A01:2021
357
- - A01:2025
358
- references:
359
- - https://pkg.go.dev/github.com/gorilla/websocket#Upgrader
360
- tags:
361
- - gorilla
362
- - id: gorm-dangerous-method-usage
363
- name: gorm-dangerous-method-usage
364
- description: >-
365
- Detected usage of dangerous method $METHOD which does not escape inputs (see link in references). If the argument
366
- is user-controlled, this can lead to SQL injection. When using $METHOD function, do not trust user-submitted data
367
- and only allow approved list of input (possibly, use an allowlist approach).
368
- category: security
369
- severity: medium
370
- confidence: medium
371
- languages:
372
- - go
373
- patterns:
374
- - regex: .*
375
- message: >-
376
- Detected usage of dangerous method $METHOD which does not escape inputs (see link in references). If the
377
- argument is user-controlled, this can lead to SQL injection. When using $METHOD function, do not trust
378
- user-submitted data and only allow approved list of input (possibly, use an allowlist approach).
379
- cwe:
380
- - CWE-89
381
- owasp:
382
- - A01:2017
383
- - A03:2021
384
- - A05:2025
385
- references:
386
- - https://gorm.io/docs/security.html#SQL-injection-Methods
387
- - https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
388
- tags:
389
- - gorm
390
- - id: grpc-client-insecure-connection
391
- name: grpc-client-insecure-connection
392
- description: >-
393
- Found an insecure gRPC connection using 'grpc.WithInsecure()'. This creates a connection without encryption to a
394
- gRPC server. A malicious attacker could tamper with the gRPC message, which could compromise the machine. Instead,
395
- establish a secure connection with an SSL certificate using the 'grpc.WithTransportCredentials()' function. You
396
- can create a create credentials using a 'tls.Config{}' struct with 'credentials.NewTLS()'. The final fix looks
397
- like this: 'grpc.WithTransportCredentials(credentials.NewTLS(<config>))'.
398
- category: security
399
- severity: high
400
- confidence: medium
401
- languages:
402
- - go
403
- patterns:
404
- - pattern: $GRPC.Dial($ADDR, ..., $GRPC.WithInsecure(...), ...)
405
- message: >-
406
- Found an insecure gRPC connection using 'grpc.WithInsecure()'. This creates a connection without encryption to
407
- a gRPC server. A malicious attacker could tamper with the gRPC message, which could compromise the machine.
408
- Instead, establish a secure connection with an SSL certificate using the 'grpc.WithTransportCredentials()'
409
- function. You can create a create credentials using a 'tls.Config{}' struct with 'credentials.NewTLS()'. The
410
- final fix looks like this: 'grpc.WithTransportCredentials(credentials.NewTLS(<config>))'.
411
- cwe:
412
- - CWE-300
413
- owasp:
414
- - A07:2021
415
- - A07:2025
416
- references:
417
- - https://blog.gopheracademy.com/advent-2019/go-grps-and-tls/#connection-without-encryption
418
- tags:
419
- - grpc
420
- - id: grpc-server-insecure-connection
421
- name: grpc-server-insecure-connection
422
- description: >-
423
- Found an insecure gRPC server without 'grpc.Creds()' or options with credentials. This allows for a connection
424
- without encryption to this server. A malicious attacker could tamper with the gRPC message, which could compromise
425
- the machine. Include credentials derived from an SSL certificate in order to create a secure gRPC connection. You
426
- can create credentials using 'credentials.NewServerTLSFromFile("cert.pem", "cert.key")'.
427
- category: security
428
- severity: high
429
- confidence: medium
430
- languages:
431
- - go
432
- patterns:
433
- - regex: .*
434
- message: >-
435
- Found an insecure gRPC server without 'grpc.Creds()' or options with credentials. This allows for a connection
436
- without encryption to this server. A malicious attacker could tamper with the gRPC message, which could
437
- compromise the machine. Include credentials derived from an SSL certificate in order to create a secure gRPC
438
- connection. You can create credentials using 'credentials.NewServerTLSFromFile("cert.pem", "cert.key")'.
439
- cwe:
440
- - CWE-300
441
- owasp:
442
- - A07:2021
443
- - A07:2025
444
- references:
445
- - https://blog.gopheracademy.com/advent-2019/go-grps-and-tls/#connection-without-encryption
446
- tags:
447
- - grpc
448
- - id: jwt-go-parse-unverified
449
- name: jwt-go-parse-unverified
450
- description: >-
451
- Detected the decoding of a JWT token without a verify step. Don't use `ParseUnverified` unless you know what
452
- you're doing This method parses the token but doesn't validate the signature. It's only ever useful in cases where
453
- you know the signature is valid (because it has been checked previously in the stack) and you want to extract
454
- values from it.
455
- category: auth
456
- severity: medium
457
- confidence: medium
458
- languages:
459
- - go
460
- patterns:
461
- - pattern: |
462
- $JWT.ParseUnverified(...)
463
- message: >-
464
- Detected the decoding of a JWT token without a verify step. Don't use `ParseUnverified` unless you know what
465
- you're doing This method parses the token but doesn't validate the signature. It's only ever useful in cases
466
- where you know the signature is valid (because it has been checked previously in the stack) and you want to
467
- extract values from it.
468
- cwe:
469
- - CWE-345
470
- owasp:
471
- - A08:2021
472
- - A08:2025
473
- references:
474
- - https://owasp.org/Top10/A08_2021-Software_and_Data_Integrity_Failures
475
- tags:
476
- - jwt
477
- - id: jwt-go-none-algorithm
478
- name: jwt-go-none-algorithm
479
- description: >-
480
- Detected use of the 'none' algorithm in a JWT token. The 'none' algorithm assumes the integrity of the token has
481
- already been verified. This would allow a malicious actor to forge a JWT token that will automatically be
482
- verified. Do not explicitly use the 'none' algorithm. Instead, use an algorithm such as 'HS256'.
483
- category: auth
484
- severity: high
485
- confidence: medium
486
- languages:
487
- - go
488
- patterns:
489
- - regex: .*
490
- message: >-
491
- Detected use of the 'none' algorithm in a JWT token. The 'none' algorithm assumes the integrity of the token
492
- has already been verified. This would allow a malicious actor to forge a JWT token that will automatically be
493
- verified. Do not explicitly use the 'none' algorithm. Instead, use an algorithm such as 'HS256'.
494
- cwe:
495
- - CWE-327
496
- owasp:
497
- - A03:2017
498
- - A02:2021
499
- - A04:2025
500
- references:
501
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
502
- tags:
503
- - jwt
504
- - id: hardcoded-jwt-key
505
- name: hardcoded-jwt-key
506
- description: >-
507
- A hard-coded credential was detected. It is not recommended to store credentials in source-code, as this risks
508
- secrets being leaked and used by either an internal or external malicious adversary. It is recommended to use
509
- environment variables to securely provide credentials or retrieve credentials from a secure vault or HSM (Hardware
510
- Security Module).
511
- category: secrets
512
- severity: medium
513
- confidence: medium
514
- languages:
515
- - go
516
- patterns:
517
- - regex: .*
518
- message: >-
519
- A hard-coded credential was detected. It is not recommended to store credentials in source-code, as this risks
520
- secrets being leaked and used by either an internal or external malicious adversary. It is recommended to use
521
- environment variables to securely provide credentials or retrieve credentials from a secure vault or HSM
522
- (Hardware Security Module).
523
- cwe:
524
- - CWE-798
525
- owasp:
526
- - A07:2021
527
- - A07:2025
528
- references:
529
- - https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
530
- tags:
531
- - jwt
532
- - secrets
533
- - id: channel-guarded-with-mutex
534
- name: channel-guarded-with-mutex
535
- description: >-
536
- Detected a channel guarded with a mutex. Channels already have an internal mutex, so this is unnecessary. Remove
537
- the mutex. See https://hackmongo.com/page/golang-antipatterns/#guarded-channel for more information.
538
- category: security
539
- severity: medium
540
- confidence: medium
541
- languages:
542
- - go
543
- patterns:
544
- - pattern: |
545
- $MUX.Lock()
546
- $VALUE <- $CHANNEL
547
- $MUX.Unlock()
548
- message: >-
549
- Detected a channel guarded with a mutex. Channels already have an internal mutex, so this is unnecessary.
550
- Remove the mutex. See https://hackmongo.com/page/golang-antipatterns/#guarded-channel for more information.
551
- - pattern: |
552
- $MUX.Lock()
553
- $VALUE = <- $CHANNEL
554
- $MUX.Unlock()
555
- message: >-
556
- Detected a channel guarded with a mutex. Channels already have an internal mutex, so this is unnecessary.
557
- Remove the mutex. See https://hackmongo.com/page/golang-antipatterns/#guarded-channel for more information.
558
- cwe: []
559
- owasp: []
560
- references: []
561
- tags:
562
- - go
563
- - id: hidden-goroutine
564
- name: hidden-goroutine
565
- description: >-
566
- Detected a hidden goroutine. Function invocations are expected to synchronous, and this function will execute
567
- asynchronously because all it does is call a goroutine. Instead, remove the internal goroutine and call the
568
- function using 'go'.
569
- category: security
570
- severity: medium
571
- confidence: medium
572
- languages:
573
- - go
574
- patterns:
575
- - pattern: |
576
- func $FUNC(...) {
577
- go func() {
578
- ...
579
- }(...)
580
- }
581
- message: >-
582
- Detected a hidden goroutine. Function invocations are expected to synchronous, and this function will execute
583
- asynchronously because all it does is call a goroutine. Instead, remove the internal goroutine and call the
584
- function using 'go'.
585
- cwe: []
586
- owasp: []
587
- references: []
588
- tags:
589
- - go
590
- - id: exported_loop_pointer
591
- name: exported_loop_pointer
592
- description: >-
593
- `$VALUE` is a loop pointer that may be exported from the loop. This pointer is shared between loop iterations, so
594
- the exported reference will always point to the last loop value, which is likely unintentional. To fix, copy the
595
- pointer to a new pointer within the loop.
596
- category: security
597
- severity: medium
598
- confidence: medium
599
- languages:
600
- - go
601
- patterns:
602
- - pattern: |
603
- for _, $VALUE := range $SOURCE {
604
- <... &($VALUE) ...>
605
- }
606
- message: >-
607
- `$VALUE` is a loop pointer that may be exported from the loop. This pointer is shared between loop iterations,
608
- so the exported reference will always point to the last loop value, which is likely unintentional. To fix,
609
- copy the pointer to a new pointer within the loop.
610
- - pattern: |
611
- for _, $VALUE := range $SOURCE {
612
- <... func() { <... &$VALUE ...> } ...>
613
- }
614
- message: >-
615
- `$VALUE` is a loop pointer that may be exported from the loop. This pointer is shared between loop iterations,
616
- so the exported reference will always point to the last loop value, which is likely unintentional. To fix,
617
- copy the pointer to a new pointer within the loop.
618
- - pattern: |
619
- for _, $VALUE := range $SOURCE {
620
- <... $ANYTHING(..., <... &$VALUE ...>, ...) ...>
621
- }
622
- message: >-
623
- `$VALUE` is a loop pointer that may be exported from the loop. This pointer is shared between loop iterations,
624
- so the exported reference will always point to the last loop value, which is likely unintentional. To fix,
625
- copy the pointer to a new pointer within the loop.
626
- cwe: []
627
- owasp: []
628
- references:
629
- - https://github.com/kyoh86/looppointer
630
- tags:
631
- - go
632
- - id: integer-overflow-int16
633
- name: integer-overflow-int16
634
- description: >-
635
- Detected conversion of the result of a strconv.Atoi command to an int16. This could lead to an integer overflow,
636
- which could possibly result in unexpected behavior and even privilege escalation. Instead, use `strconv.ParseInt`.
637
- category: security
638
- severity: medium
639
- confidence: medium
640
- languages:
641
- - go
642
- patterns:
643
- - pattern: |
644
- $F, $ERR := strconv.Atoi($NUM)
645
- ...
646
- int16($F)
647
- message: >-
648
- Detected conversion of the result of a strconv.Atoi command to an int16. This could lead to an integer
649
- overflow, which could possibly result in unexpected behavior and even privilege escalation. Instead, use
650
- `strconv.ParseInt`.
651
- cwe: []
652
- owasp: []
653
- references: []
654
- tags:
655
- - go
656
- - id: integer-overflow-int32
657
- name: integer-overflow-int32
658
- description: >-
659
- Detected conversion of the result of a strconv.Atoi command to an int32. This could lead to an integer overflow,
660
- which could possibly result in unexpected behavior and even privilege escalation. Instead, use `strconv.ParseInt`.
661
- category: security
662
- severity: medium
663
- confidence: medium
664
- languages:
665
- - go
666
- patterns:
667
- - pattern: |
668
- $F, $ERR := strconv.Atoi($NUM)
669
- ...
670
- int32($F)
671
- message: >-
672
- Detected conversion of the result of a strconv.Atoi command to an int32. This could lead to an integer
673
- overflow, which could possibly result in unexpected behavior and even privilege escalation. Instead, use
674
- `strconv.ParseInt`.
675
- cwe: []
676
- owasp: []
677
- references: []
678
- tags:
679
- - go
680
- - id: incorrect-default-permission
681
- name: incorrect-default-permission
682
- description: >-
683
- Detected file permissions that are set to more than `0600` (user/owner can read and write). Setting file
684
- permissions to higher than `0600` is most likely unnecessary and violates the principle of least privilege.
685
- Instead, set permissions to be `0600` or less for os.Chmod, os.Mkdir, os.OpenFile, os.MkdirAll, and
686
- ioutil.WriteFile
687
- category: security
688
- severity: medium
689
- confidence: medium
690
- languages:
691
- - go
692
- patterns:
693
- - regex: .*
694
- message: >-
695
- Detected file permissions that are set to more than `0600` (user/owner can read and write). Setting file
696
- permissions to higher than `0600` is most likely unnecessary and violates the principle of least privilege.
697
- Instead, set permissions to be `0600` or less for os.Chmod, os.Mkdir, os.OpenFile, os.MkdirAll, and
698
- ioutil.WriteFile
699
- cwe:
700
- - CWE-276
701
- owasp: []
702
- references:
703
- - https://github.com/securego/gosec/blob/master/rules/fileperms.go
704
- tags:
705
- - go
706
- - id: use-filepath-join
707
- name: use-filepath-join
708
- description: >-
709
- `path.Join(...)` always joins using a forward slash. This may cause issues on Windows or other systems using a
710
- different delimiter. Use `filepath.Join(...)` instead which uses OS-specific path separators.
711
- category: file-ops
712
- severity: medium
713
- confidence: medium
714
- languages:
715
- - go
716
- patterns:
717
- - regex: .*
718
- message: >-
719
- `path.Join(...)` always joins using a forward slash. This may cause issues on Windows or other systems using a
720
- different delimiter. Use `filepath.Join(...)` instead which uses OS-specific path separators.
721
- cwe: []
722
- owasp: []
723
- references:
724
- - https://parsiya.net/blog/2019-03-09-path.join-considered-harmful/
725
- - https://go.dev/src/path/path.go?s=4034:4066#L145
726
- tags:
727
- - go
728
- - id: eqeq-is-bad
729
- name: eqeq-is-bad
730
- description: >-
731
- Detected useless comparison operation `$X == $X` or `$X != $X`. This will always return 'True' or 'False' and
732
- therefore is not necessary. Instead, remove this comparison operation or use another comparison expression that is
733
- not deterministic.
734
- category: security
735
- severity: low
736
- confidence: medium
737
- languages:
738
- - go
739
- patterns:
740
- - regex: .*
741
- message: >-
742
- Detected useless comparison operation `$X == $X` or `$X != $X`. This will always return 'True' or 'False' and
743
- therefore is not necessary. Instead, remove this comparison operation or use another comparison expression
744
- that is not deterministic.
745
- cwe: []
746
- owasp: []
747
- references: []
748
- tags:
749
- - go
750
- - id: hardcoded-eq-true-or-false
751
- name: hardcoded-eq-true-or-false
752
- description: >-
753
- Detected useless if statement. 'if (True)' and 'if (False)' always result in the same behavior, and therefore is
754
- not necessary in the code. Remove the 'if (False)' expression completely or just the 'if (True)' comparison
755
- depending on which expression is in the code.
756
- category: security
757
- severity: low
758
- confidence: medium
759
- languages:
760
- - go
761
- patterns:
762
- - pattern: if (true) { ... }
763
- message: >-
764
- Detected useless if statement. 'if (True)' and 'if (False)' always result in the same behavior, and therefore
765
- is not necessary in the code. Remove the 'if (False)' expression completely or just the 'if (True)' comparison
766
- depending on which expression is in the code.
767
- - pattern: if (false) { ... }
768
- message: >-
769
- Detected useless if statement. 'if (True)' and 'if (False)' always result in the same behavior, and therefore
770
- is not necessary in the code. Remove the 'if (False)' expression completely or just the 'if (True)' comparison
771
- depending on which expression is in the code.
772
- cwe: []
773
- owasp: []
774
- references: []
775
- tags:
776
- - go
777
- - id: useless-if-conditional
778
- name: useless-if-conditional
779
- description: >-
780
- Detected an if block that checks for the same condition on both branches (`$X`). The second condition check is
781
- useless as it is the same as the first, and therefore can be removed from the code,
782
- category: security
783
- severity: medium
784
- confidence: medium
785
- languages:
786
- - go
787
- patterns:
788
- - pattern: |
789
- if ($X) {
790
- ...
791
- } else if ($X) {
792
- ...
793
- }
794
- message: >-
795
- Detected an if block that checks for the same condition on both branches (`$X`). The second condition check is
796
- useless as it is the same as the first, and therefore can be removed from the code,
797
- cwe: []
798
- owasp: []
799
- references: []
800
- tags:
801
- - go
802
- - id: useless-if-body
803
- name: useless-if-body
804
- description: >-
805
- Detected identical statements in the if body and the else body of an if-statement. This will lead to the same code
806
- being executed no matter what the if-expression evaluates to. Instead, remove the if statement.
807
- category: security
808
- severity: medium
809
- confidence: medium
810
- languages:
811
- - go
812
- patterns:
813
- - pattern: |
814
- if ($X) {
815
- $S
816
- } else {
817
- $S
818
- }
819
- message: >-
820
- Detected identical statements in the if body and the else body of an if-statement. This will lead to the same
821
- code being executed no matter what the if-expression evaluates to. Instead, remove the if statement.
822
- cwe: []
823
- owasp: []
824
- references: []
825
- tags:
826
- - go
827
- - id: insecure-module-used
828
- name: insecure-module-used
829
- description: >-
830
- The package `net/http/cgi` is on the import blocklist. The package is vulnerable to httpoxy attacks
831
- (CVE-2015-5386). It is recommended to use `net/http` or a web framework to build a web application instead.
832
- category: security
833
- severity: medium
834
- confidence: medium
835
- languages:
836
- - go
837
- patterns:
838
- - regex: .*
839
- message: >-
840
- The package `net/http/cgi` is on the import blocklist. The package is vulnerable to httpoxy attacks
841
- (CVE-2015-5386). It is recommended to use `net/http` or a web framework to build a web application instead.
842
- cwe:
843
- - CWE-327
844
- owasp:
845
- - A03:2017
846
- - A02:2021
847
- - A04:2025
848
- references:
849
- - https://godoc.org/golang.org/x/crypto/sha3
850
- tags:
851
- - go
852
- - id: avoid-ssh-insecure-ignore-host-key
853
- name: avoid-ssh-insecure-ignore-host-key
854
- description: >-
855
- Disabled host key verification detected. This allows man-in-the-middle attacks. Use the
856
- 'golang.org/x/crypto/ssh/knownhosts' package to do host key verification. See
857
- https://skarlso.github.io/2019/02/17/go-ssh-with-host-key-verification/ to learn more about the problem and how to
858
- fix it.
859
- category: secrets
860
- severity: medium
861
- confidence: medium
862
- languages:
863
- - go
864
- patterns:
865
- - pattern: ssh.InsecureIgnoreHostKey()
866
- message: >-
867
- Disabled host key verification detected. This allows man-in-the-middle attacks. Use the
868
- 'golang.org/x/crypto/ssh/knownhosts' package to do host key verification. See
869
- https://skarlso.github.io/2019/02/17/go-ssh-with-host-key-verification/ to learn more about the problem and
870
- how to fix it.
871
- cwe:
872
- - CWE-322
873
- owasp:
874
- - A02:2021
875
- - A04:2025
876
- references:
877
- - https://skarlso.github.io/2019/02/17/go-ssh-with-host-key-verification/
878
- - https://gist.github.com/Skarlso/34321a230cf0245018288686c9e70b2d
879
- tags:
880
- - go
881
- - id: math-random-used
882
- name: math-random-used
883
- description: Do not use `math/rand`. Use `crypto/rand` instead.
884
- category: security
885
- severity: medium
886
- confidence: medium
887
- languages:
888
- - go
889
- patterns:
890
- - regex: .*
891
- message: Do not use `math/rand`. Use `crypto/rand` instead.
892
- cwe:
893
- - CWE-338
894
- owasp:
895
- - A02:2021
896
- - A04:2025
897
- references:
898
- - >-
899
- https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html#secure-random-number-generation
900
- tags:
901
- - go
902
- - id: missing-ssl-minversion
903
- name: missing-ssl-minversion
904
- description: >-
905
- `MinVersion` is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as the
906
- minimum. General purpose web applications should default to TLS 1.3 with all other protocols disabled. Only where
907
- it is known that a web server must support legacy clients with unsupported an insecure browsers (such as Internet
908
- Explorer 10), it may be necessary to enable TLS 1.0 to provide support. Add `MinVersion: tls.VersionTLS13' to the
909
- TLS configuration to bump the minimum version to TLS 1.3.
910
- category: security
911
- severity: medium
912
- confidence: medium
913
- languages:
914
- - go
915
- patterns:
916
- - pattern: |
917
- tls.Config{ $...CONF }
918
- message: >-
919
- `MinVersion` is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as
920
- the minimum. General purpose web applications should default to TLS 1.3 with all other protocols disabled.
921
- Only where it is known that a web server must support legacy clients with unsupported an insecure browsers
922
- (such as Internet Explorer 10), it may be necessary to enable TLS 1.0 to provide support. Add `MinVersion:
923
- tls.VersionTLS13' to the TLS configuration to bump the minimum version to TLS 1.3.
924
- cwe:
925
- - CWE-327
926
- owasp:
927
- - A03:2017
928
- - A02:2021
929
- - A04:2025
930
- references:
931
- - https://go.dev/doc/go1.22#minor_library_changes
932
- - https://pkg.go.dev/crypto/tls#:~:text=MinVersion
933
- - https://www.us-cert.gov/ncas/alerts/TA14-290A
934
- tags:
935
- - go
936
- - id: sha224-hash
937
- name: sha224-hash
938
- description: >-
939
- This code uses a 224-bit hash function, which is deprecated or disallowed in some security policies. Consider
940
- updating to a stronger hash function such as SHA-384 or higher to ensure compliance and security.
941
- category: crypto
942
- severity: medium
943
- confidence: medium
944
- languages:
945
- - go
946
- patterns:
947
- - regex: .*
948
- message: >-
949
- This code uses a 224-bit hash function, which is deprecated or disallowed in some security policies. Consider
950
- updating to a stronger hash function such as SHA-384 or higher to ensure compliance and security.
951
- cwe:
952
- - CWE-328
953
- owasp:
954
- - A03:2017
955
- - A02:2021
956
- - A04:2025
957
- references:
958
- - https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar3.ipd.pdf
959
- - >-
960
- https://www.cyber.gov.au/resources-business-and-government/essential-cyber-security/ism/cyber-security-guidelines/guidelines-cryptography
961
- tags:
962
- - go
963
- - id: ssl-v3-is-insecure
964
- name: ssl-v3-is-insecure
965
- description: >-
966
- SSLv3 is insecure because it has known vulnerabilities. Starting with go1.14, SSLv3 will be removed. Instead, use
967
- 'tls.VersionTLS13'.
968
- category: security
969
- severity: medium
970
- confidence: medium
971
- languages:
972
- - go
973
- patterns:
974
- - pattern: 'tls.Config{..., MinVersion: $TLS.VersionSSL30, ...}'
975
- message: >-
976
- SSLv3 is insecure because it has known vulnerabilities. Starting with go1.14, SSLv3 will be removed. Instead,
977
- use 'tls.VersionTLS13'.
978
- cwe:
979
- - CWE-327
980
- owasp:
981
- - A03:2017
982
- - A02:2021
983
- - A04:2025
984
- references:
985
- - https://golang.org/doc/go1.14#crypto/tls
986
- - https://www.us-cert.gov/ncas/alerts/TA14-290A
987
- tags:
988
- - go
989
- - id: tls-with-insecure-cipher
990
- name: tls-with-insecure-cipher
991
- description: >-
992
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
993
- 'tls.CipherSuites()' to get a list of good cipher suites. See
994
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
995
- category: crypto
996
- severity: medium
997
- confidence: medium
998
- languages:
999
- - go
1000
- patterns:
1001
- - pattern: |
1002
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_RSA_WITH_RC4_128_SHA, ...}}
1003
- message: >-
1004
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1005
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1006
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1007
- - pattern: |
1008
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, ...}}
1009
- message: >-
1010
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1011
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1012
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1013
- - pattern: |
1014
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_RSA_WITH_AES_128_CBC_SHA256, ...}}
1015
- message: >-
1016
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1017
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1018
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1019
- - pattern: |
1020
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, ...}}
1021
- message: >-
1022
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1023
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1024
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1025
- - pattern: |
1026
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, ...}}
1027
- message: >-
1028
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1029
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1030
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1031
- - pattern: |
1032
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, ...}}
1033
- message: >-
1034
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1035
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1036
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1037
- - pattern: |
1038
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, ...}}
1039
- message: >-
1040
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1041
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1042
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1043
- - pattern: |
1044
- tls.Config{..., CipherSuites: []$TYPE{..., tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, ...}}
1045
- message: >-
1046
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1047
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1048
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1049
- - pattern: |
1050
- tls.CipherSuite{..., TLS_RSA_WITH_RC4_128_SHA, ...}
1051
- message: >-
1052
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1053
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1054
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1055
- - pattern: |
1056
- tls.CipherSuite{..., TLS_RSA_WITH_3DES_EDE_CBC_SHA, ...}
1057
- message: >-
1058
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1059
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1060
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1061
- - pattern: |
1062
- tls.CipherSuite{..., TLS_RSA_WITH_AES_128_CBC_SHA256, ...}
1063
- message: >-
1064
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1065
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1066
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1067
- - pattern: |
1068
- tls.CipherSuite{..., TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, ...}
1069
- message: >-
1070
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1071
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1072
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1073
- - pattern: |
1074
- tls.CipherSuite{..., TLS_ECDHE_RSA_WITH_RC4_128_SHA, ...}
1075
- message: >-
1076
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1077
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1078
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1079
- - pattern: |
1080
- tls.CipherSuite{..., TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, ...}
1081
- message: >-
1082
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1083
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1084
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1085
- - pattern: |
1086
- tls.CipherSuite{..., TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, ...}
1087
- message: >-
1088
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1089
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1090
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1091
- - pattern: |
1092
- tls.CipherSuite{..., TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, ...}
1093
- message: >-
1094
- Detected an insecure CipherSuite via the 'tls' module. This suite is considered weak. Use the function
1095
- 'tls.CipherSuites()' to get a list of good cipher suites. See
1096
- https://golang.org/pkg/crypto/tls/#InsecureCipherSuites for why and what other cipher suites to use.
1097
- cwe:
1098
- - CWE-327
1099
- owasp:
1100
- - A03:2017
1101
- - A02:2021
1102
- - A04:2025
1103
- references:
1104
- - https://golang.org/pkg/crypto/tls/#InsecureCipherSuites
1105
- tags:
1106
- - go
1107
- - id: use-of-md5
1108
- name: use-of-md5
1109
- description: >-
1110
- Detected MD5 hash algorithm which is considered insecure. MD5 is not collision resistant and is therefore not
1111
- suitable as a cryptographic signature. Use SHA256 or SHA3 instead.
1112
- category: crypto
1113
- severity: medium
1114
- confidence: medium
1115
- languages:
1116
- - go
1117
- patterns:
1118
- - regex: .*
1119
- message: >-
1120
- Detected MD5 hash algorithm which is considered insecure. MD5 is not collision resistant and is therefore not
1121
- suitable as a cryptographic signature. Use SHA256 or SHA3 instead.
1122
- cwe:
1123
- - CWE-328
1124
- owasp:
1125
- - A03:2017
1126
- - A02:2021
1127
- - A04:2025
1128
- references:
1129
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
1130
- tags:
1131
- - go
1132
- - id: use-of-sha1
1133
- name: use-of-sha1
1134
- description: >-
1135
- Detected SHA1 hash algorithm which is considered insecure. SHA1 is not collision resistant and is therefore not
1136
- suitable as a cryptographic signature. Use SHA256 or SHA3 instead.
1137
- category: security
1138
- severity: medium
1139
- confidence: medium
1140
- languages:
1141
- - go
1142
- patterns:
1143
- - regex: .*
1144
- message: >-
1145
- Detected SHA1 hash algorithm which is considered insecure. SHA1 is not collision resistant and is therefore
1146
- not suitable as a cryptographic signature. Use SHA256 or SHA3 instead.
1147
- cwe:
1148
- - CWE-328
1149
- owasp:
1150
- - A03:2017
1151
- - A02:2021
1152
- - A04:2025
1153
- references:
1154
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
1155
- tags:
1156
- - go
1157
- - id: use-of-DES
1158
- name: use-of-DES
1159
- description: >-
1160
- Detected DES cipher algorithm which is insecure. The algorithm is considered weak and has been deprecated. Use AES
1161
- instead.
1162
- category: security
1163
- severity: medium
1164
- confidence: medium
1165
- languages:
1166
- - go
1167
- patterns:
1168
- - regex: .*
1169
- message: >-
1170
- Detected DES cipher algorithm which is insecure. The algorithm is considered weak and has been deprecated. Use
1171
- AES instead.
1172
- cwe:
1173
- - CWE-327
1174
- owasp:
1175
- - A03:2017
1176
- - A02:2021
1177
- - A04:2025
1178
- references:
1179
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
1180
- tags:
1181
- - go
1182
- - id: use-of-rc4
1183
- name: use-of-rc4
1184
- description: Detected RC4 cipher algorithm which is insecure. The algorithm has many known vulnerabilities. Use AES instead.
1185
- category: security
1186
- severity: medium
1187
- confidence: medium
1188
- languages:
1189
- - go
1190
- patterns:
1191
- - pattern: rc4.NewCipher(...)
1192
- message: >-
1193
- Detected RC4 cipher algorithm which is insecure. The algorithm has many known vulnerabilities. Use AES
1194
- instead.
1195
- cwe:
1196
- - CWE-327
1197
- owasp:
1198
- - A03:2017
1199
- - A02:2021
1200
- - A04:2025
1201
- references:
1202
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
1203
- tags:
1204
- - go
1205
- - id: use-of-weak-rsa-key
1206
- name: use-of-weak-rsa-key
1207
- description: RSA keys should be at least 2048 bits
1208
- category: secrets
1209
- severity: medium
1210
- confidence: medium
1211
- languages:
1212
- - go
1213
- patterns:
1214
- - regex: .*
1215
- message: RSA keys should be at least 2048 bits
1216
- cwe:
1217
- - CWE-326
1218
- owasp:
1219
- - A03:2017
1220
- - A02:2021
1221
- - A04:2025
1222
- references:
1223
- - https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html#algorithms
1224
- tags:
1225
- - go
1226
- - id: dangerous-command-write
1227
- name: dangerous-command-write
1228
- description: >-
1229
- Detected non-static command inside Write. Audit the input to '$CW.Write'. If unverified user data can reach this
1230
- call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
1231
- arbitrary code.
1232
- category: security
1233
- severity: high
1234
- confidence: medium
1235
- languages:
1236
- - go
1237
- patterns:
1238
- - pattern: |
1239
- $CW.Write($BYTE)
1240
- message: >-
1241
- Detected non-static command inside Write. Audit the input to '$CW.Write'. If unverified user data can reach
1242
- this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to
1243
- execute arbitrary code.
1244
- cwe:
1245
- - CWE-78
1246
- owasp:
1247
- - A01:2017
1248
- - A03:2021
1249
- - A05:2025
1250
- references:
1251
- - https://owasp.org/Top10/A03_2021-Injection
1252
- tags:
1253
- - go
1254
- - id: dangerous-exec-cmd
1255
- name: dangerous-exec-cmd
1256
- description: >-
1257
- Detected non-static command inside exec.Cmd. Audit the input to 'exec.Cmd'. If unverified user data can reach this
1258
- call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
1259
- arbitrary code.
1260
- category: security
1261
- severity: high
1262
- confidence: medium
1263
- languages:
1264
- - go
1265
- patterns:
1266
- - regex: .*
1267
- message: >-
1268
- Detected non-static command inside exec.Cmd. Audit the input to 'exec.Cmd'. If unverified user data can reach
1269
- this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to
1270
- execute arbitrary code.
1271
- cwe:
1272
- - CWE-94
1273
- owasp:
1274
- - A03:2021
1275
- - A05:2025
1276
- references:
1277
- - https://owasp.org/Top10/A03_2021-Injection
1278
- tags:
1279
- - go
1280
- - id: dangerous-exec-command
1281
- name: dangerous-exec-command
1282
- description: >-
1283
- Detected non-static command inside Command. Audit the input to 'exec.Command'. If unverified user data can reach
1284
- this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
1285
- arbitrary code.
1286
- category: security
1287
- severity: high
1288
- confidence: medium
1289
- languages:
1290
- - go
1291
- patterns:
1292
- - regex: .*
1293
- message: >-
1294
- Detected non-static command inside Command. Audit the input to 'exec.Command'. If unverified user data can
1295
- reach this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script
1296
- to execute arbitrary code.
1297
- cwe:
1298
- - CWE-94
1299
- owasp:
1300
- - A03:2021
1301
- - A05:2025
1302
- references:
1303
- - https://owasp.org/Top10/A03_2021-Injection
1304
- tags:
1305
- - go
1306
- - id: dangerous-syscall-exec
1307
- name: dangerous-syscall-exec
1308
- description: >-
1309
- Detected non-static command inside Exec. Audit the input to 'syscall.Exec'. If unverified user data can reach this
1310
- call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
1311
- arbitrary code.
1312
- category: security
1313
- severity: high
1314
- confidence: medium
1315
- languages:
1316
- - go
1317
- patterns:
1318
- - regex: .*
1319
- message: >-
1320
- Detected non-static command inside Exec. Audit the input to 'syscall.Exec'. If unverified user data can reach
1321
- this call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to
1322
- execute arbitrary code.
1323
- cwe:
1324
- - CWE-94
1325
- owasp:
1326
- - A03:2021
1327
- - A05:2025
1328
- references:
1329
- - https://owasp.org/Top10/A03_2021-Injection
1330
- tags:
1331
- - go
1332
- - id: string-formatted-query
1333
- name: string-formatted-query
1334
- description: >-
1335
- String-formatted SQL query detected. This could lead to SQL injection if the string is not sanitized properly.
1336
- Audit this call to ensure the SQL is not manipulable by external data.
1337
- category: security
1338
- severity: medium
1339
- confidence: medium
1340
- languages:
1341
- - go
1342
- patterns:
1343
- - regex: .*
1344
- message: >-
1345
- String-formatted SQL query detected. This could lead to SQL injection if the string is not sanitized properly.
1346
- Audit this call to ensure the SQL is not manipulable by external data.
1347
- cwe:
1348
- - CWE-89
1349
- owasp:
1350
- - A01:2017
1351
- - A03:2021
1352
- - A05:2025
1353
- references:
1354
- - https://owasp.org/Top10/A03_2021-Injection
1355
- tags:
1356
- - go
1357
- - id: md5-used-as-password
1358
- name: md5-used-as-password
1359
- description: >-
1360
- It looks like MD5 is used as a password hash. MD5 is not considered a secure password hash because it can be
1361
- cracked by an attacker in a short amount of time. Use a suitable password hashing function such as bcrypt. You can
1362
- use the `golang.org/x/crypto/bcrypt` package.
1363
- category: secrets
1364
- severity: medium
1365
- confidence: medium
1366
- languages:
1367
- - go
1368
- patterns:
1369
- - regex: .*
1370
- message: >-
1371
- It looks like MD5 is used as a password hash. MD5 is not considered a secure password hash because it can be
1372
- cracked by an attacker in a short amount of time. Use a suitable password hashing function such as bcrypt. You
1373
- can use the `golang.org/x/crypto/bcrypt` package.
1374
- cwe:
1375
- - CWE-327
1376
- owasp:
1377
- - A03:2017
1378
- - A02:2021
1379
- - A04:2025
1380
- references:
1381
- - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
1382
- - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
1383
- - https://github.com/returntocorp/semgrep-rules/issues/1609
1384
- - https://pkg.go.dev/golang.org/x/crypto/bcrypt
1385
- tags:
1386
- - md5
1387
- - id: avoid-bind-to-all-interfaces
1388
- name: avoid-bind-to-all-interfaces
1389
- description: >-
1390
- Detected a network listener listening on 0.0.0.0 or an empty string. This could unexpectedly expose the server
1391
- publicly as it binds to all available interfaces. Instead, specify another IP address that is not 0.0.0.0 nor the
1392
- empty string.
1393
- category: security
1394
- severity: medium
1395
- confidence: medium
1396
- languages:
1397
- - go
1398
- patterns:
1399
- - pattern: tls.Listen($NETWORK, "=~/^0.0.0.0:.*$/", ...)
1400
- message: >-
1401
- Detected a network listener listening on 0.0.0.0 or an empty string. This could unexpectedly expose the server
1402
- publicly as it binds to all available interfaces. Instead, specify another IP address that is not 0.0.0.0 nor
1403
- the empty string.
1404
- - pattern: net.Listen($NETWORK, "=~/^0.0.0.0:.*$/", ...)
1405
- message: >-
1406
- Detected a network listener listening on 0.0.0.0 or an empty string. This could unexpectedly expose the server
1407
- publicly as it binds to all available interfaces. Instead, specify another IP address that is not 0.0.0.0 nor
1408
- the empty string.
1409
- - pattern: tls.Listen($NETWORK, "=~/^:.*$/", ...)
1410
- message: >-
1411
- Detected a network listener listening on 0.0.0.0 or an empty string. This could unexpectedly expose the server
1412
- publicly as it binds to all available interfaces. Instead, specify another IP address that is not 0.0.0.0 nor
1413
- the empty string.
1414
- - pattern: net.Listen($NETWORK, "=~/^:.*$/", ...)
1415
- message: >-
1416
- Detected a network listener listening on 0.0.0.0 or an empty string. This could unexpectedly expose the server
1417
- publicly as it binds to all available interfaces. Instead, specify another IP address that is not 0.0.0.0 nor
1418
- the empty string.
1419
- cwe:
1420
- - CWE-200
1421
- owasp:
1422
- - A01:2021
1423
- - A01:2025
1424
- references:
1425
- - https://owasp.org/Top10/A01_2021-Broken_Access_Control
1426
- tags:
1427
- - go
1428
- - id: cookie-missing-httponly
1429
- name: cookie-missing-httponly
1430
- description: >-
1431
- A session cookie was detected without setting the 'HttpOnly' flag. The 'HttpOnly' flag for cookies instructs the
1432
- browser to forbid client-side scripts from reading the cookie which mitigates XSS attacks. Set the 'HttpOnly' flag
1433
- by setting 'HttpOnly' to 'true' in the Cookie.
1434
- category: security
1435
- severity: medium
1436
- confidence: medium
1437
- languages:
1438
- - go
1439
- patterns:
1440
- - pattern: |
1441
- http.Cookie{
1442
- ...,
1443
- }
1444
- message: >-
1445
- A session cookie was detected without setting the 'HttpOnly' flag. The 'HttpOnly' flag for cookies instructs
1446
- the browser to forbid client-side scripts from reading the cookie which mitigates XSS attacks. Set the
1447
- 'HttpOnly' flag by setting 'HttpOnly' to 'true' in the Cookie.
1448
- cwe:
1449
- - CWE-1004
1450
- owasp:
1451
- - A05:2021
1452
- - A02:2025
1453
- references:
1454
- - https://github.com/0c34/govwa/blob/139693e56406b5684d2a6ae22c0af90717e149b8/util/cookie.go
1455
- - https://golang.org/src/net/http/cookie.go
1456
- tags:
1457
- - go
1458
- - id: cookie-missing-secure
1459
- name: cookie-missing-secure
1460
- description: >-
1461
- A session cookie was detected without setting the 'Secure' flag. The 'secure' flag for cookies prevents the client
1462
- from transmitting the cookie over insecure channels such as HTTP. Set the 'Secure' flag by setting 'Secure' to
1463
- 'true' in the Options struct.
1464
- category: security
1465
- severity: medium
1466
- confidence: medium
1467
- languages:
1468
- - go
1469
- patterns:
1470
- - pattern: |
1471
- http.Cookie{
1472
- ...,
1473
- }
1474
- message: >-
1475
- A session cookie was detected without setting the 'Secure' flag. The 'secure' flag for cookies prevents the
1476
- client from transmitting the cookie over insecure channels such as HTTP. Set the 'Secure' flag by setting
1477
- 'Secure' to 'true' in the Options struct.
1478
- cwe:
1479
- - CWE-614
1480
- owasp:
1481
- - A05:2021
1482
- - A02:2025
1483
- references:
1484
- - https://github.com/0c34/govwa/blob/139693e56406b5684d2a6ae22c0af90717e149b8/util/cookie.go
1485
- - https://golang.org/src/net/http/cookie.go
1486
- tags:
1487
- - go
1488
- - id: dynamic-httptrace-clienttrace
1489
- name: dynamic-httptrace-clienttrace
1490
- description: >-
1491
- Detected a potentially dynamic ClientTrace. This occurred because semgrep could not find a static definition for
1492
- '$TRACE'. Dynamic ClientTraces are dangerous because they deserialize function code to run when certain Request
1493
- events occur, which could lead to code being run without your knowledge. Ensure that your ClientTrace is
1494
- statically defined.
1495
- category: security
1496
- severity: medium
1497
- confidence: medium
1498
- languages:
1499
- - go
1500
- patterns:
1501
- - pattern: httptrace.WithClientTrace($ANY, $TRACE)
1502
- message: >-
1503
- Detected a potentially dynamic ClientTrace. This occurred because semgrep could not find a static definition
1504
- for '$TRACE'. Dynamic ClientTraces are dangerous because they deserialize function code to run when certain
1505
- Request events occur, which could lead to code being run without your knowledge. Ensure that your ClientTrace
1506
- is statically defined.
1507
- cwe:
1508
- - CWE-913
1509
- owasp:
1510
- - A01:2021
1511
- - A01:2025
1512
- references:
1513
- - https://github.com/returntocorp/semgrep-rules/issues/518
1514
- tags:
1515
- - go
1516
- - id: formatted-template-string
1517
- name: formatted-template-string
1518
- description: >-
1519
- Found a formatted template string passed to 'template.HTML()'. 'template.HTML()' does not escape contents. Be
1520
- absolutely sure there is no user-controlled data in this template. If user data can reach this template, you may
1521
- have a XSS vulnerability.
1522
- category: security
1523
- severity: medium
1524
- confidence: medium
1525
- languages:
1526
- - go
1527
- patterns:
1528
- - regex: .*
1529
- message: >-
1530
- Found a formatted template string passed to 'template.HTML()'. 'template.HTML()' does not escape contents. Be
1531
- absolutely sure there is no user-controlled data in this template. If user data can reach this template, you
1532
- may have a XSS vulnerability.
1533
- cwe:
1534
- - CWE-79
1535
- owasp:
1536
- - A07:2017
1537
- - A03:2021
1538
- - A05:2025
1539
- references:
1540
- - https://golang.org/pkg/html/template/#HTML
1541
- tags:
1542
- - go
1543
- - id: fs-directory-listing
1544
- name: fs-directory-listing
1545
- description: >-
1546
- Detected usage of 'http.FileServer' as handler: this allows directory listing and an attacker could navigate
1547
- through directories looking for sensitive files. Be sure to disable directory listing or restrict access to
1548
- specific directories/files.
1549
- category: security
1550
- severity: medium
1551
- confidence: medium
1552
- languages:
1553
- - go
1554
- patterns:
1555
- - regex: .*
1556
- message: >-
1557
- Detected usage of 'http.FileServer' as handler: this allows directory listing and an attacker could navigate
1558
- through directories looking for sensitive files. Be sure to disable directory listing or restrict access to
1559
- specific directories/files.
1560
- cwe:
1561
- - CWE-548
1562
- owasp:
1563
- - A06:2017
1564
- - A01:2021
1565
- - A01:2025
1566
- references:
1567
- - https://github.com/OWASP/Go-SCP
1568
- - https://cwe.mitre.org/data/definitions/548.html
1569
- tags:
1570
- - go
1571
- - id: pprof-debug-exposure
1572
- name: pprof-debug-exposure
1573
- description: >-
1574
- The profiling 'pprof' endpoint is automatically exposed on /debug/pprof. This could leak information about the
1575
- server. Instead, use `import "net/http/pprof"`. See
1576
- https://www.farsightsecurity.com/blog/txt-record/go-remote-profiling-20161028/ for more information and
1577
- mitigation.
1578
- category: security
1579
- severity: medium
1580
- confidence: medium
1581
- languages:
1582
- - go
1583
- patterns:
1584
- - pattern: http.ListenAndServe(...)
1585
- message: >-
1586
- The profiling 'pprof' endpoint is automatically exposed on /debug/pprof. This could leak information about the
1587
- server. Instead, use `import "net/http/pprof"`. See
1588
- https://www.farsightsecurity.com/blog/txt-record/go-remote-profiling-20161028/ for more information and
1589
- mitigation.
1590
- cwe:
1591
- - CWE-489
1592
- owasp:
1593
- - A06:2017
1594
- references:
1595
- - https://www.farsightsecurity.com/blog/txt-record/go-remote-profiling-20161028/
1596
- tags:
1597
- - go
1598
- - id: unescaped-data-in-htmlattr
1599
- name: unescaped-data-in-htmlattr
1600
- description: >-
1601
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1602
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the data
1603
- before passing it into the template.
1604
- category: security
1605
- severity: medium
1606
- confidence: medium
1607
- languages:
1608
- - go
1609
- patterns:
1610
- - pattern: template.HTMLAttr($T + $X, ...)
1611
- message: >-
1612
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1613
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the
1614
- data before passing it into the template.
1615
- - pattern: template.HTMLAttr(fmt.$P("...", ...), ...)
1616
- message: >-
1617
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1618
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the
1619
- data before passing it into the template.
1620
- - pattern: |
1621
- $T = "..."
1622
- ...
1623
- $T = $FXN(..., $T, ...)
1624
- ...
1625
- template.HTMLAttr($T, ...)
1626
- message: >-
1627
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1628
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the
1629
- data before passing it into the template.
1630
- - pattern: |
1631
- $T = fmt.$P("...", ...)
1632
- ...
1633
- template.HTMLAttr($T, ...)
1634
- message: >-
1635
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1636
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the
1637
- data before passing it into the template.
1638
- - pattern: |
1639
- $T, $ERR = fmt.$P("...", ...)
1640
- ...
1641
- template.HTMLAttr($T, ...)
1642
- message: >-
1643
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1644
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the
1645
- data before passing it into the template.
1646
- - pattern: |
1647
- $T = $X + $Y
1648
- ...
1649
- template.HTMLAttr($T, ...)
1650
- message: >-
1651
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1652
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the
1653
- data before passing it into the template.
1654
- - pattern: |-
1655
- $T = "..."
1656
- ...
1657
- $OTHER, $ERR = fmt.$P(..., $T, ...)
1658
- ...
1659
- template.HTMLAttr($OTHER, ...)
1660
- message: >-
1661
- Found a formatted template string passed to 'template. HTMLAttr()'. 'template.HTMLAttr()' does not escape
1662
- contents. Be absolutely sure there is no user-controlled data in this template or validate and sanitize the
1663
- data before passing it into the template.
1664
- cwe:
1665
- - CWE-79
1666
- owasp:
1667
- - A07:2017
1668
- - A03:2021
1669
- - A05:2025
1670
- references:
1671
- - https://golang.org/pkg/html/template/#HTMLAttr
1672
- tags:
1673
- - go
1674
- - id: unescaped-data-in-js
1675
- name: unescaped-data-in-js
1676
- description: >-
1677
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1678
- absolutely sure there is no user-controlled data in this template.
1679
- category: security
1680
- severity: medium
1681
- confidence: medium
1682
- languages:
1683
- - go
1684
- patterns:
1685
- - pattern: template.JS($T + $X, ...)
1686
- message: >-
1687
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1688
- absolutely sure there is no user-controlled data in this template.
1689
- - pattern: template.JS(fmt.$P("...", ...), ...)
1690
- message: >-
1691
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1692
- absolutely sure there is no user-controlled data in this template.
1693
- - pattern: |
1694
- $T = "..."
1695
- ...
1696
- $T = $FXN(..., $T, ...)
1697
- ...
1698
- template.JS($T, ...)
1699
- message: >-
1700
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1701
- absolutely sure there is no user-controlled data in this template.
1702
- - pattern: |
1703
- $T = fmt.$P("...", ...)
1704
- ...
1705
- template.JS($T, ...)
1706
- message: >-
1707
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1708
- absolutely sure there is no user-controlled data in this template.
1709
- - pattern: |
1710
- $T, $ERR = fmt.$P("...", ...)
1711
- ...
1712
- template.JS($T, ...)
1713
- message: >-
1714
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1715
- absolutely sure there is no user-controlled data in this template.
1716
- - pattern: |
1717
- $T = $X + $Y
1718
- ...
1719
- template.JS($T, ...)
1720
- message: >-
1721
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1722
- absolutely sure there is no user-controlled data in this template.
1723
- - pattern: |
1724
- $T = "..."
1725
- ...
1726
- $OTHER, $ERR = fmt.$P(..., $T, ...)
1727
- ...
1728
- template.JS($OTHER, ...)
1729
- message: >-
1730
- Found a formatted template string passed to 'template.JS()'. 'template.JS()' does not escape contents. Be
1731
- absolutely sure there is no user-controlled data in this template.
1732
- cwe:
1733
- - CWE-79
1734
- owasp:
1735
- - A07:2017
1736
- - A03:2021
1737
- - A05:2025
1738
- references:
1739
- - https://golang.org/pkg/html/template/#JS
1740
- tags:
1741
- - go
1742
- - id: unescaped-data-in-url
1743
- name: unescaped-data-in-url
1744
- description: >-
1745
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and this
1746
- could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data coming into
1747
- this function or make sure that no user-controlled input is coming into the function.
1748
- category: security
1749
- severity: medium
1750
- confidence: medium
1751
- languages:
1752
- - go
1753
- patterns:
1754
- - pattern: template.URL($T + $X, ...)
1755
- message: >-
1756
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and
1757
- this could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data
1758
- coming into this function or make sure that no user-controlled input is coming into the function.
1759
- - pattern: template.URL(fmt.$P("...", ...), ...)
1760
- message: >-
1761
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and
1762
- this could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data
1763
- coming into this function or make sure that no user-controlled input is coming into the function.
1764
- - pattern: |
1765
- $T = "..."
1766
- ...
1767
- $T = $FXN(..., $T, ...)
1768
- ...
1769
- template.URL($T, ...)
1770
- message: >-
1771
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and
1772
- this could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data
1773
- coming into this function or make sure that no user-controlled input is coming into the function.
1774
- - pattern: |
1775
- $T = fmt.$P("...", ...)
1776
- ...
1777
- template.URL($T, ...)
1778
- message: >-
1779
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and
1780
- this could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data
1781
- coming into this function or make sure that no user-controlled input is coming into the function.
1782
- - pattern: |
1783
- $T, $ERR = fmt.$P("...", ...)
1784
- ...
1785
- template.URL($T, ...)
1786
- message: >-
1787
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and
1788
- this could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data
1789
- coming into this function or make sure that no user-controlled input is coming into the function.
1790
- - pattern: |
1791
- $T = $X + $Y
1792
- ...
1793
- template.URL($T, ...)
1794
- message: >-
1795
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and
1796
- this could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data
1797
- coming into this function or make sure that no user-controlled input is coming into the function.
1798
- - pattern: |-
1799
- $T = "..."
1800
- ...
1801
- $OTHER, $ERR = fmt.$P(..., $T, ...)
1802
- ...
1803
- template.URL($OTHER, ...)
1804
- message: >-
1805
- Found a formatted template string passed to 'template.URL()'. 'template.URL()' does not escape contents, and
1806
- this could result in XSS (cross-site scripting) and therefore confidential data being stolen. Sanitize data
1807
- coming into this function or make sure that no user-controlled input is coming into the function.
1808
- cwe:
1809
- - CWE-79
1810
- owasp:
1811
- - A07:2017
1812
- - A03:2021
1813
- - A05:2025
1814
- references:
1815
- - https://golang.org/pkg/html/template/#URL
1816
- tags:
1817
- - go
1818
- - id: use-tls
1819
- name: use-tls
1820
- description: >-
1821
- Found an HTTP server without TLS. Use 'http.ListenAndServeTLS' instead. See
1822
- https://golang.org/pkg/net/http/#ListenAndServeTLS for more information.
1823
- category: security
1824
- severity: medium
1825
- confidence: medium
1826
- languages:
1827
- - go
1828
- patterns:
1829
- - pattern: http.ListenAndServe($ADDR, $HANDLER)
1830
- message: >-
1831
- Found an HTTP server without TLS. Use 'http.ListenAndServeTLS' instead. See
1832
- https://golang.org/pkg/net/http/#ListenAndServeTLS for more information.
1833
- cwe:
1834
- - CWE-319
1835
- owasp:
1836
- - A03:2017
1837
- - A02:2021
1838
- - A04:2025
1839
- references:
1840
- - https://golang.org/pkg/net/http/#ListenAndServeTLS
1841
- tags:
1842
- - go
1843
- - id: wip-xss-using-responsewriter-and-printf
1844
- name: wip-xss-using-responsewriter-and-printf
1845
- description: >-
1846
- Found data going from url query parameters into formatted data written to ResponseWriter. This could be XSS and
1847
- should not be done. If you must do this, ensure your data is sanitized or escaped.
1848
- category: xss
1849
- severity: medium
1850
- confidence: medium
1851
- languages:
1852
- - go
1853
- patterns:
1854
- - regex: .*
1855
- message: >-
1856
- Found data going from url query parameters into formatted data written to ResponseWriter. This could be XSS
1857
- and should not be done. If you must do this, ensure your data is sanitized or escaped.
1858
- cwe:
1859
- - CWE-79
1860
- owasp:
1861
- - A07:2017
1862
- - A03:2021
1863
- - A05:2025
1864
- references:
1865
- - https://owasp.org/Top10/A03_2021-Injection
1866
- tags:
1867
- - go
1868
- - id: reflect-makefunc
1869
- name: reflect-makefunc
1870
- description: >-
1871
- 'reflect.MakeFunc' detected. This will sidestep protections that are normally afforded by Go's type system. Audit
1872
- this call and be sure that user input cannot be used to affect the code generated by MakeFunc; otherwise, you will
1873
- have a serious security vulnerability.
1874
- category: security
1875
- severity: high
1876
- confidence: medium
1877
- languages:
1878
- - go
1879
- patterns:
1880
- - pattern: reflect.MakeFunc(...)
1881
- message: >-
1882
- 'reflect.MakeFunc' detected. This will sidestep protections that are normally afforded by Go's type system.
1883
- Audit this call and be sure that user input cannot be used to affect the code generated by MakeFunc;
1884
- otherwise, you will have a serious security vulnerability.
1885
- cwe:
1886
- - CWE-913
1887
- owasp:
1888
- - A01:2021
1889
- - A01:2025
1890
- references:
1891
- - https://owasp.org/Top10/A01_2021-Broken_Access_Control
1892
- tags:
1893
- - go
1894
- - id: gosql-sqli
1895
- name: gosql-sqli
1896
- description: >-
1897
- Detected string concatenation with a non-literal variable in a "database/sql" Go SQL statement. This could lead to
1898
- SQL injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection,
1899
- use parameterized queries or prepared statements instead. You can use prepared statements with the 'Prepare' and
1900
- 'PrepareContext' calls.
1901
- category: injection
1902
- severity: high
1903
- confidence: medium
1904
- languages:
1905
- - go
1906
- patterns:
1907
- - regex: .*
1908
- message: >-
1909
- Detected string concatenation with a non-literal variable in a "database/sql" Go SQL statement. This could
1910
- lead to SQL injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL
1911
- injection, use parameterized queries or prepared statements instead. You can use prepared statements with the
1912
- 'Prepare' and 'PrepareContext' calls.
1913
- cwe:
1914
- - CWE-89
1915
- owasp:
1916
- - A01:2017
1917
- - A03:2021
1918
- - A05:2025
1919
- references:
1920
- - https://golang.org/pkg/database/sql/
1921
- tags:
1922
- - go
1923
- - id: pg-orm-sqli
1924
- name: pg-orm-sqli
1925
- description: >-
1926
- Detected string concatenation with a non-literal variable in a go-pg ORM SQL statement. This could lead to SQL
1927
- injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection, do not
1928
- use strings concatenated with user-controlled input. Instead, use parameterized statements.
1929
- category: injection
1930
- severity: high
1931
- confidence: medium
1932
- languages:
1933
- - go
1934
- patterns:
1935
- - regex: .*
1936
- message: >-
1937
- Detected string concatenation with a non-literal variable in a go-pg ORM SQL statement. This could lead to SQL
1938
- injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection, do
1939
- not use strings concatenated with user-controlled input. Instead, use parameterized statements.
1940
- cwe:
1941
- - CWE-89
1942
- owasp:
1943
- - A01:2017
1944
- - A03:2021
1945
- - A05:2025
1946
- references:
1947
- - https://pg.uptrace.dev/queries/
1948
- tags:
1949
- - go-pg
1950
- - id: pg-sqli
1951
- name: pg-sqli
1952
- description: >-
1953
- Detected string concatenation with a non-literal variable in a go-pg SQL statement. This could lead to SQL
1954
- injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection, use
1955
- parameterized queries instead of string concatenation. You can use parameterized queries like so: '(SELECT ? FROM
1956
- table, data1)'
1957
- category: injection
1958
- severity: high
1959
- confidence: medium
1960
- languages:
1961
- - go
1962
- patterns:
1963
- - regex: .*
1964
- message: >-
1965
- Detected string concatenation with a non-literal variable in a go-pg SQL statement. This could lead to SQL
1966
- injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection,
1967
- use parameterized queries instead of string concatenation. You can use parameterized queries like so: '(SELECT
1968
- ? FROM table, data1)'
1969
- cwe:
1970
- - CWE-89
1971
- owasp:
1972
- - A01:2017
1973
- - A03:2021
1974
- - A05:2025
1975
- references:
1976
- - https://pg.uptrace.dev/
1977
- - https://pkg.go.dev/github.com/go-pg/pg/v10
1978
- tags:
1979
- - go-pg
1980
- - id: pgx-sqli
1981
- name: pgx-sqli
1982
- description: >-
1983
- Detected string concatenation with a non-literal variable in a pgx Go SQL statement. This could lead to SQL
1984
- injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection, use
1985
- parameterized queries instead. You can use parameterized queries like so: (`SELECT $1 FROM table`, `data1)
1986
- category: injection
1987
- severity: high
1988
- confidence: medium
1989
- languages:
1990
- - go
1991
- patterns:
1992
- - regex: .*
1993
- message: >-
1994
- Detected string concatenation with a non-literal variable in a pgx Go SQL statement. This could lead to SQL
1995
- injection if the variable is user-controlled and not properly sanitized. In order to prevent SQL injection,
1996
- use parameterized queries instead. You can use parameterized queries like so: (`SELECT $1 FROM table`, `data1)
1997
- cwe:
1998
- - CWE-89
1999
- owasp:
2000
- - A01:2017
2001
- - A03:2021
2002
- - A05:2025
2003
- references:
2004
- - https://github.com/jackc/pgx
2005
- - https://pkg.go.dev/github.com/jackc/pgx/v4#hdr-Connection_Pool
2006
- tags:
2007
- - pgx
2008
- - id: unsafe-reflect-by-name
2009
- name: unsafe-reflect-by-name
2010
- description: >-
2011
- If an attacker can supply values that the application then uses to determine which method or field to invoke, the
2012
- potential exists for the attacker to create control flow paths through the application that were not intended by
2013
- the application developers. This attack vector may allow the attacker to bypass authentication or access control
2014
- checks or otherwise cause the application to behave in an unexpected manner.
2015
- category: security
2016
- severity: medium
2017
- confidence: medium
2018
- languages:
2019
- - go
2020
- patterns:
2021
- - regex: .*
2022
- message: >-
2023
- If an attacker can supply values that the application then uses to determine which method or field to invoke,
2024
- the potential exists for the attacker to create control flow paths through the application that were not
2025
- intended by the application developers. This attack vector may allow the attacker to bypass authentication or
2026
- access control checks or otherwise cause the application to behave in an unexpected manner.
2027
- cwe:
2028
- - CWE-470
2029
- owasp:
2030
- - A03:2021
2031
- - A05:2025
2032
- references:
2033
- - https://owasp.org/Top10/A03_2021-Injection
2034
- tags:
2035
- - go
2036
- - id: use-of-unsafe-block
2037
- name: use-of-unsafe-block
2038
- description: >-
2039
- Using the unsafe package in Go gives you low-level memory management and many of the strengths of the C language,
2040
- but also steps around the type safety of Go and can lead to buffer overflows and possible arbitrary code execution
2041
- by an attacker. Only use this package if you absolutely know what you're doing.
2042
- category: security
2043
- severity: medium
2044
- confidence: medium
2045
- languages:
2046
- - go
2047
- patterns:
2048
- - pattern: unsafe.$FUNC(...)
2049
- message: >-
2050
- Using the unsafe package in Go gives you low-level memory management and many of the strengths of the C
2051
- language, but also steps around the type safety of Go and can lead to buffer overflows and possible arbitrary
2052
- code execution by an attacker. Only use this package if you absolutely know what you're doing.
2053
- cwe:
2054
- - CWE-242
2055
- owasp: []
2056
- references:
2057
- - https://cwe.mitre.org/data/definitions/242.html
2058
- tags:
2059
- - go
2060
- - id: import-text-template
2061
- name: import-text-template
2062
- description: >-
2063
- When working with web applications that involve rendering user-generated content, it's important to properly
2064
- escape any HTML content to prevent Cross-Site Scripting (XSS) attacks. In Go, the `text/template` package does
2065
- not automatically escape HTML content, which can leave your application vulnerable to these types of attacks. To
2066
- mitigate this risk, it's recommended to use the `html/template` package instead, which provides built-in
2067
- functionality for HTML escaping. By using `html/template` to render your HTML content, you can help to ensure
2068
- that your web application is more secure and less susceptible to XSS vulnerabilities.
2069
- category: security
2070
- severity: medium
2071
- confidence: medium
2072
- languages:
2073
- - go
2074
- patterns:
2075
- - pattern: |
2076
- import "$IMPORT"
2077
- message: >-
2078
- When working with web applications that involve rendering user-generated content, it's important to properly
2079
- escape any HTML content to prevent Cross-Site Scripting (XSS) attacks. In Go, the `text/template` package
2080
- does not automatically escape HTML content, which can leave your application vulnerable to these types of
2081
- attacks. To mitigate this risk, it's recommended to use the `html/template` package instead, which provides
2082
- built-in functionality for HTML escaping. By using `html/template` to render your HTML content, you can help
2083
- to ensure that your web application is more secure and less susceptible to XSS vulnerabilities.
2084
- cwe:
2085
- - CWE-79
2086
- owasp:
2087
- - A07:2017
2088
- - A03:2021
2089
- - A05:2025
2090
- references:
2091
- - https://www.veracode.com/blog/secure-development/use-golang-these-mistakes-could-compromise-your-apps-security
2092
- tags:
2093
- - go
2094
- - id: no-direct-write-to-responsewriter
2095
- name: no-direct-write-to-responsewriter
2096
- description: >-
2097
- Detected directly writing or similar in 'http.ResponseWriter.write()'. This bypasses HTML escaping that prevents
2098
- cross-site scripting vulnerabilities. Instead, use the 'html/template' package and render data using
2099
- 'template.Execute()'.
2100
- category: security
2101
- severity: medium
2102
- confidence: medium
2103
- languages:
2104
- - go
2105
- patterns:
2106
- - regex: .*
2107
- message: >-
2108
- Detected directly writing or similar in 'http.ResponseWriter.write()'. This bypasses HTML escaping that
2109
- prevents cross-site scripting vulnerabilities. Instead, use the 'html/template' package and render data using
2110
- 'template.Execute()'.
2111
- cwe:
2112
- - CWE-79
2113
- owasp:
2114
- - A07:2017
2115
- - A03:2021
2116
- - A05:2025
2117
- references:
2118
- - https://blogtitle.github.io/robn-go-security-pearls-cross-site-scripting-xss/
2119
- tags:
2120
- - go
2121
- - id: no-fprintf-to-responsewriter
2122
- name: no-fprintf-to-responsewriter
2123
- description: >-
2124
- Detected 'Fprintf' or similar writing to 'http.ResponseWriter'. This bypasses HTML escaping that prevents
2125
- cross-site scripting vulnerabilities. Instead, use the 'html/template' package to render data to users.
2126
- category: security
2127
- severity: medium
2128
- confidence: medium
2129
- languages:
2130
- - go
2131
- patterns:
2132
- - pattern: fmt.$PRINTF($WRITER, ...)
2133
- message: >-
2134
- Detected 'Fprintf' or similar writing to 'http.ResponseWriter'. This bypasses HTML escaping that prevents
2135
- cross-site scripting vulnerabilities. Instead, use the 'html/template' package to render data to users.
2136
- cwe:
2137
- - CWE-79
2138
- owasp:
2139
- - A07:2017
2140
- - A03:2021
2141
- - A05:2025
2142
- references:
2143
- - https://blogtitle.github.io/robn-go-security-pearls-cross-site-scripting-xss/
2144
- tags:
2145
- - go
2146
- - id: no-io-writestring-to-responsewriter
2147
- name: no-io-writestring-to-responsewriter
2148
- description: >-
2149
- Detected 'io.WriteString()' writing directly to 'http.ResponseWriter'. This bypasses HTML escaping that prevents
2150
- cross-site scripting vulnerabilities. Instead, use the 'html/template' package to render data to users.
2151
- category: security
2152
- severity: medium
2153
- confidence: medium
2154
- languages:
2155
- - go
2156
- patterns:
2157
- - pattern: io.WriteString($WRITER, $STRING)
2158
- message: >-
2159
- Detected 'io.WriteString()' writing directly to 'http.ResponseWriter'. This bypasses HTML escaping that
2160
- prevents cross-site scripting vulnerabilities. Instead, use the 'html/template' package to render data to
2161
- users.
2162
- cwe:
2163
- - CWE-79
2164
- owasp:
2165
- - A07:2017
2166
- - A03:2021
2167
- - A05:2025
2168
- references:
2169
- - https://blogtitle.github.io/robn-go-security-pearls-cross-site-scripting-xss/
2170
- - https://golang.org/pkg/io/#WriteString
2171
- tags:
2172
- - go
2173
- - id: no-printf-in-responsewriter
2174
- name: no-printf-in-responsewriter
2175
- description: >-
2176
- Detected 'printf' or similar in 'http.ResponseWriter.write()'. This bypasses HTML escaping that prevents
2177
- cross-site scripting vulnerabilities. Instead, use the 'html/template' package to render data to users.
2178
- category: security
2179
- severity: medium
2180
- confidence: medium
2181
- languages:
2182
- - go
2183
- patterns:
2184
- - pattern: |
2185
- $WRITER.Write(<... fmt.$PRINTF(...) ...>, ...)
2186
- message: >-
2187
- Detected 'printf' or similar in 'http.ResponseWriter.write()'. This bypasses HTML escaping that prevents
2188
- cross-site scripting vulnerabilities. Instead, use the 'html/template' package to render data to users.
2189
- cwe:
2190
- - CWE-79
2191
- owasp:
2192
- - A07:2017
2193
- - A03:2021
2194
- - A05:2025
2195
- references:
2196
- - https://blogtitle.github.io/robn-go-security-pearls-cross-site-scripting-xss/
2197
- tags:
2198
- - go
2199
- - id: unsafe-template-type
2200
- name: unsafe-template-type
2201
- description: >-
2202
- Semgrep could not determine that the argument to 'template.HTML()' is a constant. 'template.HTML()' and similar
2203
- does not escape contents. Be absolutely sure there is no user-controlled data in this template. If user data can
2204
- reach this template, you may have a XSS vulnerability. Instead, do not use this function and use
2205
- 'template.Execute()'.
2206
- category: security
2207
- severity: medium
2208
- confidence: medium
2209
- languages:
2210
- - go
2211
- patterns:
2212
- - regex: .*
2213
- message: >-
2214
- Semgrep could not determine that the argument to 'template.HTML()' is a constant. 'template.HTML()' and
2215
- similar does not escape contents. Be absolutely sure there is no user-controlled data in this template. If
2216
- user data can reach this template, you may have a XSS vulnerability. Instead, do not use this function and use
2217
- 'template.Execute()'.
2218
- cwe:
2219
- - CWE-79
2220
- owasp:
2221
- - A07:2017
2222
- - A03:2021
2223
- - A05:2025
2224
- references:
2225
- - https://golang.org/pkg/html/template/#HTML
2226
- - https://github.com/0c34/govwa/blob/139693e56406b5684d2a6ae22c0af90717e149b8/vulnerability/xss/xss.go#L33
2227
- tags:
2228
- - go
2229
- - id: parsing-external-entities-enabled
2230
- name: parsing-external-entities-enabled
2231
- description: >-
2232
- Detected enabling of "XMLParseNoEnt", which allows parsing of external entities and can lead to XXE if user
2233
- controlled data is parsed by the library. Instead, do not enable "XMLParseNoEnt" or be sure to adequately sanitize
2234
- user-controlled data when it is being parsed by this library.
2235
- category: security
2236
- severity: medium
2237
- confidence: medium
2238
- languages:
2239
- - go
2240
- patterns:
2241
- - pattern: $PARSER := parser.New(parser.XMLParseNoEnt)
2242
- message: >-
2243
- Detected enabling of "XMLParseNoEnt", which allows parsing of external entities and can lead to XXE if user
2244
- controlled data is parsed by the library. Instead, do not enable "XMLParseNoEnt" or be sure to adequately
2245
- sanitize user-controlled data when it is being parsed by this library.
2246
- cwe:
2247
- - CWE-611
2248
- owasp:
2249
- - A04:2017
2250
- - A05:2021
2251
- - A02:2025
2252
- references:
2253
- - https://knowledge-base.secureflag.com/vulnerabilities/xml_injection/xml_entity_expansion_go_lang.html
2254
- - https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing
2255
- tags:
2256
- - libxml2
2257
- - id: bad-tmp-file-creation
2258
- name: bad-tmp-file-creation
2259
- description: File creation in shared tmp directory without using `io.CreateTemp`.
2260
- category: file-ops
2261
- severity: medium
2262
- confidence: medium
2263
- languages:
2264
- - go
2265
- patterns:
2266
- - pattern: ioutil.WriteFile("=~//tmp/.*$/", ...)
2267
- message: File creation in shared tmp directory without using `io.CreateTemp`.
2268
- - pattern: os.Create("=~//tmp/.*$/", ...)
2269
- message: File creation in shared tmp directory without using `io.CreateTemp`.
2270
- - pattern: os.WriteFile("=~//tmp/.*$/", ...)
2271
- message: File creation in shared tmp directory without using `io.CreateTemp`.
2272
- cwe:
2273
- - CWE-377
2274
- owasp:
2275
- - A01:2021
2276
- - A01:2025
2277
- references:
2278
- - https://owasp.org/Top10/A01_2021-Broken_Access_Control
2279
- - https://pkg.go.dev/io/ioutil#TempFile
2280
- - https://pkg.go.dev/os#CreateTemp
2281
- - https://github.com/securego/gosec/blob/5fd2a370447223541cddb35da8d1bc707b7bb153/rules/tempfiles.go#L67
2282
- tags:
2283
- - go
2284
- - id: potential-dos-via-decompression-bomb
2285
- name: potential-dos-via-decompression-bomb
2286
- description: >-
2287
- Detected a possible denial-of-service via a zip bomb attack. By limiting the max bytes read, you can mitigate this
2288
- attack. `io.CopyN()` can specify a size.
2289
- category: security
2290
- severity: medium
2291
- confidence: medium
2292
- languages:
2293
- - go
2294
- patterns:
2295
- - regex: .*
2296
- message: >-
2297
- Detected a possible denial-of-service via a zip bomb attack. By limiting the max bytes read, you can mitigate
2298
- this attack. `io.CopyN()` can specify a size.
2299
- cwe:
2300
- - CWE-400
2301
- owasp: []
2302
- references:
2303
- - https://golang.org/pkg/io/#CopyN
2304
- - https://github.com/securego/gosec/blob/master/rules/decompression-bomb.go
2305
- tags:
2306
- - go
2307
- - id: go-unsafe-deserialization-interface
2308
- name: go-unsafe-deserialization-interface
2309
- description: >-
2310
- Deserializing into `interface{}` allows arbitrary data structures and types, which can lead to security
2311
- vulnerabilities (CWE-502). Use a concrete struct type instead.
2312
- category: security
2313
- severity: medium
2314
- confidence: medium
2315
- languages:
2316
- - go
2317
- patterns:
2318
- - regex: .*
2319
- message: >-
2320
- Deserializing into `interface{}` allows arbitrary data structures and types, which can lead to security
2321
- vulnerabilities (CWE-502). Use a concrete struct type instead.
2322
- cwe:
2323
- - CWE-502
2324
- owasp:
2325
- - A08:2017
2326
- - A08:2021
2327
- references:
2328
- - https://cwe.mitre.org/data/definitions/502.html
2329
- tags:
2330
- - go
2331
- - id: filepath-clean-misuse
2332
- name: filepath-clean-misuse
2333
- description: >-
2334
- `Clean` is not intended to sanitize against path traversal attacks. This function is for finding the shortest path
2335
- name equivalent to the given input. Using `Clean` to sanitize file reads may expose this application to path
2336
- traversal attacks, where an attacker could access arbitrary files on the server. To fix this easily, write this:
2337
- `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))` However, a better solution is using the
2338
- `SecureJoin` function in the package `filepath-securejoin`. See
2339
- https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme.
2340
- category: file-ops
2341
- severity: high
2342
- confidence: medium
2343
- languages:
2344
- - go
2345
- patterns:
2346
- - regex: .*
2347
- message: >-
2348
- `Clean` is not intended to sanitize against path traversal attacks. This function is for finding the shortest
2349
- path name equivalent to the given input. Using `Clean` to sanitize file reads may expose this application to
2350
- path traversal attacks, where an attacker could access arbitrary files on the server. To fix this easily,
2351
- write this: `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))` However, a better solution
2352
- is using the `SecureJoin` function in the package `filepath-securejoin`. See
2353
- https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme.
2354
- cwe:
2355
- - CWE-22
2356
- owasp:
2357
- - A05:2017
2358
- - A01:2021
2359
- - A01:2025
2360
- references:
2361
- - https://pkg.go.dev/path#Clean
2362
- - http://technosophos.com/2016/03/31/go-quickly-cleaning-filepaths.html
2363
- - https://labs.detectify.com/2021/12/15/zero-day-path-traversal-grafana/
2364
- - https://dzx.cz/2021/04/02/go_path_traversal/
2365
- - https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme
2366
- tags:
2367
- - go
2368
- - id: open-redirect
2369
- name: open-redirect
2370
- description: >-
2371
- An HTTP redirect was found to be crafted from user-input `$REQUEST`. This can lead to open redirect
2372
- vulnerabilities, potentially allowing attackers to redirect users to malicious web sites. It is recommend where
2373
- possible to not allow user-input to craft the redirect URL. When user-input is necessary to craft the request, it
2374
- is recommended to follow OWASP best practices to restrict the URL to domains in an allowlist.
2375
- category: security
2376
- severity: medium
2377
- confidence: medium
2378
- languages:
2379
- - go
2380
- patterns:
2381
- - regex: .*
2382
- message: >-
2383
- An HTTP redirect was found to be crafted from user-input `$REQUEST`. This can lead to open redirect
2384
- vulnerabilities, potentially allowing attackers to redirect users to malicious web sites. It is recommend
2385
- where possible to not allow user-input to craft the redirect URL. When user-input is necessary to craft the
2386
- request, it is recommended to follow OWASP best practices to restrict the URL to domains in an allowlist.
2387
- cwe:
2388
- - CWE-601
2389
- owasp: []
2390
- references:
2391
- - >-
2392
- https://knowledge-base.secureflag.com/vulnerabilities/unvalidated_redirects___forwards/open_redirect_go_lang.html
2393
- tags:
2394
- - go
2395
- - id: raw-html-format
2396
- name: raw-html-format
2397
- description: >-
2398
- Detected user input flowing into a manually constructed HTML string. You may be accidentally bypassing secure
2399
- methods of rendering HTML by manually constructing HTML and this could create a cross-site scripting
2400
- vulnerability, which could let attackers steal sensitive user data. Use the `html/template` package which will
2401
- safely render HTML instead, or inspect that the HTML is rendered safely.
2402
- category: security
2403
- severity: medium
2404
- confidence: medium
2405
- languages:
2406
- - go
2407
- patterns:
2408
- - regex: .*
2409
- message: >-
2410
- Detected user input flowing into a manually constructed HTML string. You may be accidentally bypassing secure
2411
- methods of rendering HTML by manually constructing HTML and this could create a cross-site scripting
2412
- vulnerability, which could let attackers steal sensitive user data. Use the `html/template` package which will
2413
- safely render HTML instead, or inspect that the HTML is rendered safely.
2414
- cwe:
2415
- - CWE-79
2416
- owasp:
2417
- - A07:2017
2418
- - A03:2021
2419
- - A05:2025
2420
- references:
2421
- - https://blogtitle.github.io/robn-go-security-pearls-cross-site-scripting-xss/
2422
- tags:
2423
- - go
2424
- - id: tainted-url-host
2425
- name: tainted-url-host
2426
- description: >-
2427
- A request was found to be crafted from user-input `$REQUEST`. This can lead to Server-Side Request Forgery (SSRF)
2428
- vulnerabilities, potentially exposing sensitive data. It is recommend where possible to not allow user-input to
2429
- craft the base request, but to be treated as part of the path or query parameter. When user-input is necessary to
2430
- craft the request, it is recommended to follow OWASP best practices to prevent abuse, including using an
2431
- allowlist.
2432
- category: security
2433
- severity: medium
2434
- confidence: medium
2435
- languages:
2436
- - go
2437
- patterns:
2438
- - regex: .*
2439
- message: >-
2440
- A request was found to be crafted from user-input `$REQUEST`. This can lead to Server-Side Request Forgery
2441
- (SSRF) vulnerabilities, potentially exposing sensitive data. It is recommend where possible to not allow
2442
- user-input to craft the base request, but to be treated as part of the path or query parameter. When
2443
- user-input is necessary to craft the request, it is recommended to follow OWASP best practices to prevent
2444
- abuse, including using an allowlist.
2445
- cwe:
2446
- - CWE-918
2447
- owasp:
2448
- - A10:2021
2449
- - A01:2025
2450
- references:
2451
- - https://goteleport.com/blog/ssrf-attacks/
2452
- tags:
2453
- - go
2454
- - id: reverseproxy-director
2455
- name: reverseproxy-director
2456
- description: >-
2457
- ReverseProxy can remove headers added by Director. Consider using ReverseProxy.Rewrite instead of
2458
- ReverseProxy.Director.
2459
- category: security
2460
- severity: medium
2461
- confidence: medium
2462
- languages:
2463
- - go
2464
- patterns:
2465
- - regex: .*
2466
- message: >-
2467
- ReverseProxy can remove headers added by Director. Consider using ReverseProxy.Rewrite instead of
2468
- ReverseProxy.Director.
2469
- cwe:
2470
- - CWE-115
2471
- owasp: []
2472
- references:
2473
- - https://github.com/golang/go/issues/50580
2474
- tags:
2475
- - go
2476
- - id: shared-url-struct-mutation
2477
- name: shared-url-struct-mutation
2478
- description: Shared URL struct may have been accidentally mutated. Ensure that this behavior is intended.
2479
- category: security
2480
- severity: medium
2481
- confidence: medium
2482
- languages:
2483
- - go
2484
- patterns:
2485
- - regex: .*
2486
- message: Shared URL struct may have been accidentally mutated. Ensure that this behavior is intended.
2487
- cwe:
2488
- - CWE-436
2489
- owasp: []
2490
- references:
2491
- - https://github.com/golang/go/issues/63777
2492
- tags:
2493
- - go
2494
- - id: path-traversal-inside-zip-extraction
2495
- name: path-traversal-inside-zip-extraction
2496
- description: File traversal when extracting zip archive
2497
- category: file-ops
2498
- severity: medium
2499
- confidence: medium
2500
- languages:
2501
- - go
2502
- patterns:
2503
- - pattern: |
2504
- reader, $ERR := zip.OpenReader($ARCHIVE)
2505
- ...
2506
- for _, $FILE := range reader.File {
2507
- ...
2508
- path := filepath.Join($TARGET, $FILE.Name)
2509
- ...
2510
- }
2511
- message: File traversal when extracting zip archive
2512
- cwe:
2513
- - CWE-22
2514
- owasp:
2515
- - A05:2017
2516
- - A01:2021
2517
- - A01:2025
2518
- references:
2519
- - https://owasp.org/Top10/A01_2021-Broken_Access_Control
2520
- tags:
2521
- - go
2522
- - id: dangerous-execution
2523
- name: dangerous-execution
2524
- description: >-
2525
- Detected non-static script inside otto VM. Audit the input to 'VM.Run'. If unverified user data can reach this
2526
- call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
2527
- arbitrary code.
2528
- category: security
2529
- severity: high
2530
- confidence: medium
2531
- languages:
2532
- - go
2533
- patterns:
2534
- - pattern: $VM.Run(...)
2535
- message: >-
2536
- Detected non-static script inside otto VM. Audit the input to 'VM.Run'. If unverified user data can reach this
2537
- call site, this is a code injection vulnerability. A malicious actor can inject a malicious script to execute
2538
- arbitrary code.
2539
- cwe:
2540
- - CWE-94
2541
- owasp:
2542
- - A03:2021
2543
- - A05:2025
2544
- references:
2545
- - https://owasp.org/Top10/A03_2021-Injection
2546
- tags:
2547
- - otto
2548
- - vm
2549
- - id: go-insecure-templates
2550
- name: go-insecure-templates
2551
- description: >-
2552
- usage of insecure template types. They are documented as a security risk. See
2553
- https://golang.org/pkg/html/template/#HTML.
2554
- category: security
2555
- severity: medium
2556
- confidence: medium
2557
- languages:
2558
- - go
2559
- patterns:
2560
- - regex: .*
2561
- message: >-
2562
- usage of insecure template types. They are documented as a security risk. See
2563
- https://golang.org/pkg/html/template/#HTML.
2564
- cwe:
2565
- - CWE-79
2566
- owasp:
2567
- - A07:2017
2568
- - A03:2021
2569
- - A05:2025
2570
- references:
2571
- - https://golang.org/pkg/html/template/#HTML
2572
- - https://twitter.com/empijei/status/1275177219011350528
2573
- tags:
2574
- - template
2575
- - id: go-ssti
2576
- name: go-ssti
2577
- description: >-
2578
- A server-side template injection occurs when an attacker is able to use native template syntax to inject a
2579
- malicious payload into a template, which is then executed server-side. When using "html/template" always check
2580
- that user inputs are validated and sanitized before included within the template.
2581
- category: security
2582
- severity: high
2583
- confidence: medium
2584
- languages:
2585
- - go
2586
- patterns:
2587
- - pattern: $TEMPLATE = fmt.Sprintf("...", $ARG, ...)
2588
- message: >-
2589
- A server-side template injection occurs when an attacker is able to use native template syntax to inject a
2590
- malicious payload into a template, which is then executed server-side. When using "html/template" always check
2591
- that user inputs are validated and sanitized before included within the template.
2592
- cwe:
2593
- - CWE-1336
2594
- owasp: []
2595
- references:
2596
- - https://www.onsecurity.io/blog/go-ssti-method-research/
2597
- - http://blog.takemyhand.xyz/2020/05/ssti-breaking-gos-template-engine-to.html
2598
- tags:
2599
- - go
2600
- - id: bypass-tls-verification
2601
- name: bypass-tls-verification
2602
- description: >-
2603
- Checks for disabling of TLS/SSL certificate verification. This should only be used for debugging purposes because
2604
- it leads to vulnerability to MTM attacks.
2605
- category: security
2606
- severity: medium
2607
- confidence: medium
2608
- languages:
2609
- - go
2610
- patterns:
2611
- - pattern: |
2612
- tls.Config{..., InsecureSkipVerify: true, ...}
2613
- message: >-
2614
- Checks for disabling of TLS/SSL certificate verification. This should only be used for debugging purposes
2615
- because it leads to vulnerability to MTM attacks.
2616
- - pattern: |
2617
- $CONFIG = &tls.Config{...}
2618
- ...
2619
- $CONFIG.InsecureSkipVerify = true
2620
- message: >-
2621
- Checks for disabling of TLS/SSL certificate verification. This should only be used for debugging purposes
2622
- because it leads to vulnerability to MTM attacks.
2623
- cwe:
2624
- - CWE-319
2625
- owasp:
2626
- - A03:2017
2627
- references:
2628
- - https://stackoverflow.com/questions/12122159/how-to-do-a-https-request-with-bad-certificate
2629
- tags:
2630
- - go
2631
- - id: disallow-old-tls-versions
2632
- name: disallow-old-tls-versions
2633
- description: >-
2634
- Detects creations of tls configuration objects with an insecure MinVersion of TLS. These protocols are deprecated
2635
- due to POODLE, man in the middle attacks, and other vulnerabilities.
2636
- category: security
2637
- severity: medium
2638
- confidence: medium
2639
- languages:
2640
- - go
2641
- patterns:
2642
- - regex: .*
2643
- message: >-
2644
- Detects creations of tls configuration objects with an insecure MinVersion of TLS. These protocols are
2645
- deprecated due to POODLE, man in the middle attacks, and other vulnerabilities.
2646
- cwe:
2647
- - CWE-319
2648
- owasp:
2649
- - A03:2017
2650
- references:
2651
- - https://stackoverflow.com/questions/26429751/java-http-clients-and-poodle
2652
- tags:
2653
- - go
2654
- - id: ftp-request
2655
- name: ftp-request
2656
- description: >-
2657
- Checks for outgoing connections to ftp servers with the ftp package. FTP does not encrypt traffic, possibly
2658
- leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
2659
- category: security
2660
- severity: medium
2661
- confidence: medium
2662
- languages:
2663
- - go
2664
- patterns:
2665
- - pattern: |
2666
- ftp.Dial("=~/^[fF][tT][pP]://.*/", ...)
2667
- message: >-
2668
- Checks for outgoing connections to ftp servers with the ftp package. FTP does not encrypt traffic, possibly
2669
- leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
2670
- - pattern: |
2671
- ftp.DialTimeout("=~/^[fF][tT][pP]://.*/", ...)
2672
- message: >-
2673
- Checks for outgoing connections to ftp servers with the ftp package. FTP does not encrypt traffic, possibly
2674
- leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
2675
- - pattern: |
2676
- ftp.Connect("=~/^[fF][tT][pP]://.*/")
2677
- message: >-
2678
- Checks for outgoing connections to ftp servers with the ftp package. FTP does not encrypt traffic, possibly
2679
- leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
2680
- - pattern: |
2681
- $URL = "=~/^[fF][tT][pP]://.*/"
2682
- ...
2683
- ftp.Dial($URL, ...)
2684
- message: >-
2685
- Checks for outgoing connections to ftp servers with the ftp package. FTP does not encrypt traffic, possibly
2686
- leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
2687
- - pattern: |
2688
- $URL = "=~/^[fF][tT][pP]://.*/"
2689
- ...
2690
- ftp.DialTimeout($URL, ...)
2691
- message: >-
2692
- Checks for outgoing connections to ftp servers with the ftp package. FTP does not encrypt traffic, possibly
2693
- leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
2694
- - pattern: |
2695
- $URL = "=~/^[fF][tT][pP]://.*/"
2696
- ...
2697
- ftp.Connect($URL)
2698
- message: >-
2699
- Checks for outgoing connections to ftp servers with the ftp package. FTP does not encrypt traffic, possibly
2700
- leading to PII being sent plaintext over the network. Instead, connect via the SFTP protocol.
2701
- cwe:
2702
- - CWE-319
2703
- owasp:
2704
- - A03:2017
2705
- references:
2706
- - https://godoc.org/github.com/jlaffaye/ftp#Dial
2707
- - https://github.com/jlaffaye/ftp
2708
- tags:
2709
- - ftp
2710
- - id: gorequest-http-request
2711
- name: gorequest-http-request
2712
- description: >-
2713
- Checks for requests to http (unencrypted) sites using gorequest, a popular HTTP client library. This is dangerous
2714
- because it could result in plaintext PII being passed around the network.
2715
- category: security
2716
- severity: medium
2717
- confidence: medium
2718
- languages:
2719
- - go
2720
- patterns:
2721
- - regex: .*
2722
- message: >-
2723
- Checks for requests to http (unencrypted) sites using gorequest, a popular HTTP client library. This is
2724
- dangerous because it could result in plaintext PII being passed around the network.
2725
- cwe:
2726
- - CWE-319
2727
- owasp:
2728
- - A03:2017
2729
- references:
2730
- - https://github.com/parnurzeal/gorequest
2731
- tags:
2732
- - gorequest
2733
- - id: grequests-http-request
2734
- name: grequests-http-request
2735
- description: >-
2736
- Checks for requests to http (unencrypted) sites using grequests, a popular HTTP client library. This is dangerous
2737
- because it could result in plaintext PII being passed around the network.
2738
- category: security
2739
- severity: medium
2740
- confidence: medium
2741
- languages:
2742
- - go
2743
- patterns:
2744
- - regex: .*
2745
- message: >-
2746
- Checks for requests to http (unencrypted) sites using grequests, a popular HTTP client library. This is
2747
- dangerous because it could result in plaintext PII being passed around the network.
2748
- cwe:
2749
- - CWE-319
2750
- owasp:
2751
- - A03:2017
2752
- references:
2753
- - https://godoc.org/github.com/levigross/grequests#DoRegularRequest
2754
- - https://github.com/levigross/grequests
2755
- tags:
2756
- - grequests
2757
- - id: http-customized-request
2758
- name: http-customized-request
2759
- description: >-
2760
- Checks for requests sent via http.NewRequest to http:// URLS. This is dangerous because the server is attempting
2761
- to connect to a website that does not encrypt traffic with TLS. Instead, send requests only to https:// URLS.
2762
- category: security
2763
- severity: medium
2764
- confidence: medium
2765
- languages:
2766
- - go
2767
- patterns:
2768
- - pattern: |
2769
- http.NewRequest(..., "=~/[hH][tT][tT][pP]://.*/", ...)
2770
- message: >-
2771
- Checks for requests sent via http.NewRequest to http:// URLS. This is dangerous because the server is
2772
- attempting to connect to a website that does not encrypt traffic with TLS. Instead, send requests only to
2773
- https:// URLS.
2774
- cwe:
2775
- - CWE-319
2776
- owasp:
2777
- - A03:2017
2778
- references:
2779
- - https://golang.org/pkg/net/http/#NewRequest
2780
- tags:
2781
- - go
2782
- - id: http-request
2783
- name: http-request
2784
- description: >-
2785
- Checks for requests sent via http.$FUNC to http:// URLS. This is dangerous because the server is attempting to
2786
- connect to a website that does not encrypt traffic with TLS. Instead, send requests only to https:// URLS.
2787
- category: security
2788
- severity: medium
2789
- confidence: medium
2790
- languages:
2791
- - go
2792
- patterns:
2793
- - regex: .*
2794
- message: >-
2795
- Checks for requests sent via http.$FUNC to http:// URLS. This is dangerous because the server is attempting to
2796
- connect to a website that does not encrypt traffic with TLS. Instead, send requests only to https:// URLS.
2797
- cwe:
2798
- - CWE-319
2799
- owasp:
2800
- - A03:2017
2801
- references:
2802
- - https://golang.org/pkg/net/http/#Get
2803
- tags:
2804
- - go
2805
- - id: sling-http-request
2806
- name: sling-http-request
2807
- description: >-
2808
- Checks for requests to http (unencrypted) sites using gorequest, a popular HTTP client library. This is dangerous
2809
- because it could result in plaintext PII being passed around the network.
2810
- category: security
2811
- severity: medium
2812
- confidence: medium
2813
- languages:
2814
- - go
2815
- patterns:
2816
- - regex: .*
2817
- message: >-
2818
- Checks for requests to http (unencrypted) sites using gorequest, a popular HTTP client library. This is
2819
- dangerous because it could result in plaintext PII being passed around the network.
2820
- cwe:
2821
- - CWE-319
2822
- owasp:
2823
- - A03:2017
2824
- references:
2825
- - https://godoc.org/github.com/dghubble/sling#Sling.Add
2826
- - https://github.com/dghubble/sling
2827
- tags:
2828
- - sling
2829
- - id: telnet-request
2830
- name: telnet-request
2831
- description: >-
2832
- Checks for attempts to connect to an insecure telnet server using the package telnet. This is bad because it can
2833
- lead to man in the middle attacks.
2834
- category: security
2835
- severity: medium
2836
- confidence: medium
2837
- languages:
2838
- - go
2839
- patterns:
2840
- - pattern: |
2841
- telnet.DialToAndCall(...)
2842
- message: >-
2843
- Checks for attempts to connect to an insecure telnet server using the package telnet. This is bad because it
2844
- can lead to man in the middle attacks.
2845
- cwe:
2846
- - CWE-319
2847
- owasp:
2848
- - A03:2017
2849
- references:
2850
- - https://godoc.org/github.com/reiver/go-telnet
2851
- tags:
2852
- - go-telnet
2853
- - id: libxml2-xxe-taint
2854
- name: libxml2-xxe-taint
2855
- description: >-
2856
- The application is using an XML parser that has not been safely configured. This might lead to XML External Entity
2857
- (XXE) vulnerabilities when parsing user-controlled input. An attacker can include document type definitions (DTDs)
2858
- which can interact with internal or external hosts. XXE can lead to other vulnerabilities, such as Local File
2859
- Inclusion (LFI), Remote Code Execution (RCE), and Server-side request forgery (SSRF), depending on the application
2860
- configuration. An attacker can also use DTDs to expand recursively, leading to a Denial-of-Service (DoS) attack,
2861
- also known as a `Billion Laughs Attack`. The best defense against XXE is to have an XML parser that supports
2862
- disabling DTDs. Limiting the use of external entities from the start can prevent the parser from being used to
2863
- process untrusted XML files. Reducing dependencies on external resources is also a good practice for performance
2864
- reasons. It is difficult to guarantee that even a trusted XML file on your server or during transmission has not
2865
- been tampered with by a malicious third-party.
2866
- category: api-security
2867
- severity: high
2868
- confidence: medium
2869
- languages:
2870
- - go
2871
- patterns:
2872
- - regex: .*
2873
- message: >-
2874
- The application is using an XML parser that has not been safely configured. This might lead to XML External
2875
- Entity (XXE) vulnerabilities when parsing user-controlled input. An attacker can include document type
2876
- definitions (DTDs) which can interact with internal or external hosts. XXE can lead to other vulnerabilities,
2877
- such as Local File Inclusion (LFI), Remote Code Execution (RCE), and Server-side request forgery (SSRF),
2878
- depending on the application configuration. An attacker can also use DTDs to expand recursively, leading to a
2879
- Denial-of-Service (DoS) attack, also known as a `Billion Laughs Attack`. The best defense against XXE is to
2880
- have an XML parser that supports disabling DTDs. Limiting the use of external entities from the start can
2881
- prevent the parser from being used to process untrusted XML files. Reducing dependencies on external resources
2882
- is also a good practice for performance reasons. It is difficult to guarantee that even a trusted XML file on
2883
- your server or during transmission has not been tampered with by a malicious third-party.
2884
- cwe:
2885
- - CWE-611
2886
- owasp:
2887
- - A04:2017
2888
- - A05:2021
2889
- - A02:2025
2890
- references:
2891
- - https://owasp.org/Top10/A05_2021-Security_Misconfiguration
2892
- tags:
2893
- - go
2894
- - libxml2
2895
- - go
2896
- - go-net/http
2897
- - gin
2898
- - gin-gonic/gin