codesentry-semgrep-rules 0.1.11 → 0.2.1

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.
package/rules/owasp.yml CHANGED
@@ -17122,138 +17122,6 @@ rules:
17122
17122
  pattern-sanitizers:
17123
17123
  - pattern: params.merge(:only_path => true)
17124
17124
  - pattern: params.merge(:host => ...)
17125
- - id: ruby.rails.security.audit.xss.avoid-render-dynamic-path.avoid-render-dynamic-path
17126
- metadata:
17127
- owasp:
17128
- - A05:2017 - Broken Access Control
17129
- - A01:2021 - Broken Access Control
17130
- - A01:2025 - Broken Access Control
17131
- cwe:
17132
- - 'CWE-22: Improper Limitation of a Pathname to a Restricted Directory (''Path
17133
- Traversal'')'
17134
- references:
17135
- - https://brakemanscanner.org/docs/warning_types/dynamic_render_paths/
17136
- category: security
17137
- technology:
17138
- - rails
17139
- cwe2022-top25: true
17140
- cwe2021-top25: true
17141
- subcategory:
17142
- - vuln
17143
- likelihood: HIGH
17144
- impact: MEDIUM
17145
- confidence: MEDIUM
17146
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17147
- vulnerability_class:
17148
- - Path Traversal
17149
- source: https://semgrep.dev/r/ruby.rails.security.audit.xss.avoid-render-dynamic-path.avoid-render-dynamic-path
17150
- shortlink: https://sg.run/GO2n
17151
- semgrep.dev:
17152
- rule:
17153
- r_id: 13592
17154
- rv_id: 1263635
17155
- rule_id: 6JU1bL
17156
- version_id: bZT53p0
17157
- url: https://semgrep.dev/playground/r/bZT53p0/ruby.rails.security.audit.xss.avoid-render-dynamic-path.avoid-render-dynamic-path
17158
- origin: community
17159
- message: Avoid rendering user input. It may be possible for a malicious user to
17160
- input a path that lets them access a template they shouldn't. To prevent this,
17161
- check dynamic template paths against a predefined allowlist to make sure it's
17162
- an allowed template.
17163
- languages:
17164
- - ruby
17165
- severity: WARNING
17166
- mode: taint
17167
- pattern-sources:
17168
- - pattern: params
17169
- - pattern: cookies
17170
- - pattern: request.env
17171
- pattern-sinks:
17172
- - patterns:
17173
- - pattern-inside: render($X => $INPUT, ...)
17174
- - pattern: $INPUT
17175
- - metavariable-pattern:
17176
- metavariable: $X
17177
- pattern-either:
17178
- - pattern: action
17179
- - pattern: template
17180
- - pattern: partial
17181
- - pattern: file
17182
- - id: python.lang.security.audit.insecure-file-permissions.insecure-file-permissions
17183
- languages:
17184
- - python
17185
- severity: WARNING
17186
- metadata:
17187
- category: security
17188
- owasp:
17189
- - A01:2021 - Broken Access Control
17190
- - A01:2025 - Broken Access Control
17191
- cwe:
17192
- - 'CWE-276: Incorrect Default Permissions'
17193
- technology:
17194
- - python
17195
- references:
17196
- - https://owasp.org/Top10/A01_2021-Broken_Access_Control
17197
- cwe2022-top25: true
17198
- cwe2021-top25: true
17199
- subcategory:
17200
- - vuln
17201
- likelihood: LOW
17202
- impact: MEDIUM
17203
- confidence: MEDIUM
17204
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17205
- vulnerability_class:
17206
- - Improper Authorization
17207
- source: https://semgrep.dev/r/python.lang.security.audit.insecure-file-permissions.insecure-file-permissions
17208
- shortlink: https://sg.run/AXY4
17209
- semgrep.dev:
17210
- rule:
17211
- r_id: 13594
17212
- rv_id: 1263482
17213
- rule_id: zdUYqR
17214
- version_id: O9Tpxqr
17215
- url: https://semgrep.dev/playground/r/O9Tpxqr/python.lang.security.audit.insecure-file-permissions.insecure-file-permissions
17216
- origin: community
17217
- message: These permissions `$BITS` are widely permissive and grant access to more
17218
- people than may be necessary. A good default is `0o644` which gives read and write
17219
- access to yourself and read access to everyone else.
17220
- patterns:
17221
- - pattern-inside: os.$METHOD(...)
17222
- - metavariable-pattern:
17223
- metavariable: $METHOD
17224
- patterns:
17225
- - pattern-either:
17226
- - pattern: chmod
17227
- - pattern: lchmod
17228
- - pattern: fchmod
17229
- - pattern-either:
17230
- - patterns:
17231
- - pattern: os.$METHOD($FILE, $BITS, ...)
17232
- - metavariable-comparison:
17233
- metavariable: $BITS
17234
- comparison: $BITS >= 0o650 and $BITS < 0o100000
17235
- - patterns:
17236
- - pattern: os.$METHOD($FILE, $BITS)
17237
- - metavariable-comparison:
17238
- metavariable: $BITS
17239
- comparison: $BITS >= 0o100650
17240
- - patterns:
17241
- - pattern: os.$METHOD($FILE, $BITS, ...)
17242
- - metavariable-pattern:
17243
- metavariable: $BITS
17244
- patterns:
17245
- - pattern-either:
17246
- - pattern: <... stat.S_IWGRP ...>
17247
- - pattern: <... stat.S_IXGRP ...>
17248
- - pattern: <... stat.S_IWOTH ...>
17249
- - pattern: <... stat.S_IXOTH ...>
17250
- - pattern: <... stat.S_IRWXO ...>
17251
- - pattern: <... stat.S_IRWXG ...>
17252
- - patterns:
17253
- - pattern: os.$METHOD($FILE, $EXPR | $MOD, ...)
17254
- - metavariable-comparison:
17255
- metavariable: $MOD
17256
- comparison: $MOD == 0o111
17257
17125
  - id: php.doctrine.security.audit.doctrine-orm-dangerous-query.doctrine-orm-dangerous-query
17258
17126
  languages:
17259
17127
  - php
@@ -17650,479 +17518,530 @@ rules:
17650
17518
  metavariable: $HTMLSTR
17651
17519
  language: generic
17652
17520
  pattern: <$TAG ...
17653
- - id: go.lang.security.injection.tainted-sql-string.tainted-sql-string
17521
+ - id: ruby.rails.security.injection.raw-html-format.raw-html-format
17654
17522
  languages:
17655
- - go
17656
- message: User data flows into this manually-constructed SQL string. User data can
17657
- be safely inserted into SQL strings using prepared statements or an object-relational
17658
- mapper (ORM). Manually-constructed SQL strings is a possible indicator of SQL
17659
- injection, which could let an attacker steal or manipulate data from the database.
17660
- Instead, use prepared statements (`db.Query("SELECT * FROM t WHERE id = ?", id)`)
17661
- or a safe library.
17662
- options:
17663
- interfile: true
17523
+ - ruby
17524
+ severity: WARNING
17525
+ message: Detected user input flowing into a manually constructed HTML string. You
17526
+ may be accidentally bypassing secure methods of rendering HTML by manually constructing
17527
+ HTML and this could create a cross-site scripting vulnerability, which could let
17528
+ attackers steal sensitive user data. Use the `render template` and make template
17529
+ files which will safely render HTML instead, or inspect that the HTML is absolutely
17530
+ rendered safely with a function like `sanitize`.
17664
17531
  metadata:
17665
17532
  cwe:
17666
- - 'CWE-89: Improper Neutralization of Special Elements used in an SQL Command
17667
- (''SQL Injection'')'
17533
+ - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
17534
+ Scripting'')'
17668
17535
  owasp:
17669
- - A01:2017 - Injection
17536
+ - A07:2017 - Cross-Site Scripting (XSS)
17670
17537
  - A03:2021 - Injection
17671
17538
  - A05:2025 - Injection
17672
- references:
17673
- - https://golang.org/doc/database/sql-injection
17674
- - https://www.stackhawk.com/blog/golang-sql-injection-guide-examples-and-prevention/
17675
17539
  category: security
17676
17540
  technology:
17677
- - go
17678
- confidence: HIGH
17541
+ - rails
17542
+ references:
17543
+ - https://www.netsparker.com/blog/web-security/preventing-xss-ruby-on-rails-web-applications/
17544
+ - https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html
17679
17545
  cwe2022-top25: true
17680
17546
  cwe2021-top25: true
17681
17547
  subcategory:
17682
17548
  - vuln
17683
17549
  likelihood: HIGH
17684
17550
  impact: MEDIUM
17685
- interfile: true
17551
+ confidence: MEDIUM
17686
17552
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17687
17553
  vulnerability_class:
17688
- - SQL Injection
17689
- source: https://semgrep.dev/r/go.lang.security.injection.tainted-sql-string.tainted-sql-string
17690
- shortlink: https://sg.run/PbEq
17554
+ - Cross-Site-Scripting (XSS)
17555
+ source: https://semgrep.dev/r/ruby.rails.security.injection.raw-html-format.raw-html-format
17556
+ shortlink: https://sg.run/b2JQ
17691
17557
  semgrep.dev:
17692
17558
  rule:
17693
- r_id: 14689
17694
- rv_id: 1409388
17695
- rule_id: PeUoqy
17696
- version_id: nWTQ5qD
17697
- url: https://semgrep.dev/playground/r/nWTQ5qD/go.lang.security.injection.tainted-sql-string.tainted-sql-string
17559
+ r_id: 14470
17560
+ rv_id: 1409408
17561
+ rule_id: kxUwZX
17562
+ version_id: qkTvgYY
17563
+ url: https://semgrep.dev/playground/r/qkTvgYY/ruby.rails.security.injection.raw-html-format.raw-html-format
17698
17564
  origin: community
17699
17565
  mode: taint
17700
- severity: ERROR
17566
+ pattern-sanitizers:
17567
+ - pattern-either:
17568
+ - pattern: sanitize(...)
17569
+ - pattern: strip_tags(...)
17701
17570
  pattern-sources:
17702
17571
  - patterns:
17703
17572
  - pattern-either:
17704
- - pattern: |
17705
- ($REQUEST : *http.Request).$ANYTHING
17706
- - pattern: |
17707
- ($REQUEST : http.Request).$ANYTHING
17708
- - metavariable-regex:
17709
- metavariable: $ANYTHING
17710
- regex: ^(BasicAuth|Body|Cookie|Cookies|Form|FormValue|GetBody|Host|MultipartReader|ParseForm|ParseMultipartForm|PostForm|PostFormValue|Referer|RequestURI|Trailer|TransferEncoding|UserAgent|URL)$
17573
+ - pattern: params
17574
+ - pattern: request
17711
17575
  pattern-sinks:
17712
17576
  - patterns:
17713
17577
  - pattern-either:
17714
17578
  - patterns:
17715
- - pattern-either:
17716
- - pattern: |
17717
- "$SQLSTR" + ...
17718
- - patterns:
17719
- - pattern-inside: |
17720
- $VAR = "$SQLSTR";
17721
- ...
17722
- - pattern: $VAR += ...
17723
- - patterns:
17724
- - pattern-inside: |
17725
- var $SB strings.Builder
17726
- ...
17727
- - pattern-inside: |
17728
- $SB.WriteString("$SQLSTR")
17729
- ...
17730
- $SB.String(...)
17731
- - pattern: |
17732
- $SB.WriteString(...)
17733
- - metavariable-regex:
17734
- metavariable: $SQLSTR
17735
- regex: (?i)(select|delete|insert|create|update|alter|drop).*
17579
+ - pattern: |
17580
+ $HTMLSTR
17581
+ - pattern-regex: <\w+.*
17736
17582
  - patterns:
17737
17583
  - pattern-either:
17738
- - pattern: fmt.Fprintf($F, "$SQLSTR", ...)
17739
- - pattern: fmt.Sprintf("$SQLSTR", ...)
17740
- - pattern: fmt.Printf("$SQLSTR", ...)
17741
- - metavariable-regex:
17742
- metavariable: $SQLSTR
17743
- regex: \s*(?i)(select|delete|insert|create|update|alter|drop)\b.*%(v|s|q).*
17744
- pattern-sanitizers:
17745
- - pattern-either:
17746
- - pattern: strconv.Atoi(...)
17747
- - pattern: |
17748
- ($X: bool)
17749
- - id: java.lang.security.audit.md5-used-as-password.md5-used-as-password
17750
- languages:
17751
- - java
17584
+ - pattern: Kernel::sprintf("$HTMLSTR", ...)
17585
+ - pattern: |
17586
+ "$HTMLSTR" + $EXPR
17587
+ - pattern: |
17588
+ "$HTMLSTR" % $EXPR
17589
+ - metavariable-pattern:
17590
+ metavariable: $HTMLSTR
17591
+ language: generic
17592
+ pattern: <$TAG ...
17593
+ - id: bash.curl.security.curl-eval.curl-eval
17752
17594
  severity: WARNING
17753
- message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
17754
- password hash because it can be cracked by an attacker in a short amount of time.
17755
- Use a suitable password hashing function such as PBKDF2 or bcrypt. You can use
17756
- `javax.crypto.SecretKeyFactory` with `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")`
17757
- or, if using Spring, `org.springframework.security.crypto.bcrypt`.
17758
- metadata:
17759
- category: security
17760
- technology:
17761
- - java
17762
- - md5
17763
- references:
17764
- - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
17765
- - https://github.com/returntocorp/semgrep-rules/issues/1609
17766
- - https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SecretKeyFactory
17767
- - https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoder.html
17595
+ languages:
17596
+ - bash
17597
+ message: Data is being eval'd from a `curl` command. An attacker with control of
17598
+ the server in the `curl` command could inject malicious code into the `eval`,
17599
+ resulting in a system comrpomise. Avoid eval'ing untrusted data if you can. If
17600
+ you must do this, consider checking the SHA sum of the content returned by the
17601
+ server to verify its integrity.
17602
+ metadata:
17768
17603
  owasp:
17769
- - A03:2017 - Sensitive Data Exposure
17770
- - A02:2021 - Cryptographic Failures
17771
- - A04:2025 - Cryptographic Failures
17604
+ - A03:2021 - Injection
17605
+ - A05:2025 - Injection
17772
17606
  cwe:
17773
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17607
+ - 'CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code
17608
+ (''Eval Injection'')'
17609
+ category: security
17610
+ technology:
17611
+ - bash
17612
+ - curl
17613
+ confidence: MEDIUM
17614
+ references:
17615
+ - https://owasp.org/Top10/A03_2021-Injection
17774
17616
  subcategory:
17775
17617
  - vuln
17776
- likelihood: HIGH
17618
+ likelihood: MEDIUM
17777
17619
  impact: MEDIUM
17778
- confidence: MEDIUM
17779
17620
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17780
17621
  vulnerability_class:
17781
- - Cryptographic Issues
17782
- source: https://semgrep.dev/r/java.lang.security.audit.md5-used-as-password.md5-used-as-password
17783
- shortlink: https://sg.run/JxEQ
17622
+ - Code Injection
17623
+ source: https://semgrep.dev/r/bash.curl.security.curl-eval.curl-eval
17624
+ shortlink: https://sg.run/0yqJ
17784
17625
  semgrep.dev:
17785
17626
  rule:
17786
- r_id: 14690
17787
- rv_id: 1263029
17788
- rule_id: JDULAW
17789
- version_id: bZT53QB
17790
- url: https://semgrep.dev/playground/r/bZT53QB/java.lang.security.audit.md5-used-as-password.md5-used-as-password
17627
+ r_id: 14554
17628
+ rv_id: 1262601
17629
+ rule_id: KxU7Rq
17630
+ version_id: JdTzxL2
17631
+ url: https://semgrep.dev/playground/r/JdTzxL2/bash.curl.security.curl-eval.curl-eval
17791
17632
  origin: community
17792
17633
  mode: taint
17793
17634
  pattern-sources:
17794
- - patterns:
17795
- - pattern-inside: |
17796
- $TYPE $MD = MessageDigest.getInstance("MD5");
17797
- ...
17798
- - pattern: $MD.digest(...);
17635
+ - pattern: |
17636
+ $(curl ...)
17637
+ - pattern: |
17638
+ `curl ...`
17799
17639
  pattern-sinks:
17800
- - patterns:
17801
- - pattern: $MODEL.$METHOD(...);
17802
- - metavariable-regex:
17803
- metavariable: $METHOD
17804
- regex: (?i)(.*password.*)
17805
- - id: javascript.express.security.injection.raw-html-format.raw-html-format
17806
- message: User data flows into the host portion of this manually-constructed HTML.
17807
- This can introduce a Cross-Site-Scripting (XSS) vulnerability if this comes from
17808
- user-provided input. Consider using a sanitization library such as DOMPurify to
17809
- sanitize the HTML within.
17640
+ - pattern: eval ...
17641
+ - id: python.flask.security.injection.tainted-url-host.tainted-url-host
17642
+ languages:
17643
+ - python
17644
+ message: User data flows into the host portion of this manually-constructed URL.
17645
+ This could allow an attacker to send data to their own server, potentially exposing
17646
+ sensitive data such as cookies or authorization information sent with this request.
17647
+ They could also probe internal servers or other resources that the server running
17648
+ this code can access. (This is called server-side request forgery, or SSRF.) Do
17649
+ not allow arbitrary hosts. Instead, create an allowlist for approved hosts, or
17650
+ hardcode the correct host.
17810
17651
  metadata:
17811
17652
  cwe:
17812
- - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
17813
- Scripting'')'
17653
+ - 'CWE-918: Server-Side Request Forgery (SSRF)'
17814
17654
  owasp:
17815
- - A07:2017 - Cross-Site Scripting (XSS)
17816
- - A03:2021 - Injection
17817
- - A05:2025 - Injection
17655
+ - A10:2021 - Server-Side Request Forgery (SSRF)
17656
+ - A01:2025 - Broken Access Control
17818
17657
  references:
17819
- - https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
17658
+ - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
17820
17659
  category: security
17821
17660
  technology:
17822
- - express
17661
+ - flask
17823
17662
  cwe2022-top25: true
17824
17663
  cwe2021-top25: true
17825
17664
  subcategory:
17826
17665
  - vuln
17827
- likelihood: HIGH
17828
17666
  impact: MEDIUM
17667
+ likelihood: MEDIUM
17829
17668
  confidence: MEDIUM
17830
17669
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17831
17670
  vulnerability_class:
17832
- - Cross-Site-Scripting (XSS)
17833
- source: https://semgrep.dev/r/javascript.express.security.injection.raw-html-format.raw-html-format
17834
- shortlink: https://sg.run/5DO3
17671
+ - Server-Side Request Forgery (SSRF)
17672
+ source: https://semgrep.dev/r/python.flask.security.injection.tainted-url-host.tainted-url-host
17673
+ shortlink: https://sg.run/RXpK
17835
17674
  semgrep.dev:
17836
17675
  rule:
17837
- r_id: 14691
17838
- rv_id: 1263175
17839
- rule_id: 5rUL0X
17840
- version_id: NdTzyQv
17841
- url: https://semgrep.dev/playground/r/NdTzyQv/javascript.express.security.injection.raw-html-format.raw-html-format
17676
+ r_id: 14649
17677
+ rv_id: 1409403
17678
+ rule_id: ReU3Wb
17679
+ version_id: BjTy42w
17680
+ url: https://semgrep.dev/playground/r/BjTy42w/python.flask.security.injection.tainted-url-host.tainted-url-host
17842
17681
  origin: community
17843
- languages:
17844
- - javascript
17845
- - typescript
17846
- severity: WARNING
17847
17682
  mode: taint
17848
- pattern-sources:
17849
- - label: EXPRESS
17850
- patterns:
17851
- - pattern-either:
17852
- - pattern-inside: function ... ($REQ, $RES) {...}
17853
- - pattern-inside: function ... ($REQ, $RES, $NEXT) {...}
17854
- - patterns:
17855
- - pattern-either:
17856
- - pattern-inside: $APP.$METHOD(..., function $FUNC($REQ, $RES) {...})
17857
- - pattern-inside: $APP.$METHOD(..., function $FUNC($REQ, $RES, $NEXT) {...})
17858
- - metavariable-regex:
17859
- metavariable: $METHOD
17860
- regex: ^(get|post|put|head|delete|options)$
17861
- - pattern-either:
17862
- - pattern: $REQ.query
17863
- - pattern: $REQ.body
17864
- - pattern: $REQ.params
17865
- - pattern: $REQ.cookies
17866
- - pattern: $REQ.headers
17867
- - label: EXPRESSTS
17868
- patterns:
17869
- - pattern-either:
17870
- - pattern-inside: |
17871
- ({ $REQ }: Request,$RES: Response, $NEXT: NextFunction) =>
17872
- {...}
17873
- - pattern-inside: |
17874
- ({ $REQ }: Request,$RES: Response) => {...}
17875
- - focus-metavariable: $REQ
17876
- - pattern-either:
17877
- - pattern: params
17878
- - pattern: query
17879
- - pattern: cookies
17880
- - pattern: headers
17881
- - pattern: body
17882
- - label: CLEAN
17883
- by-side-effect: true
17884
- patterns:
17885
- - pattern-either:
17886
- - pattern: $A($SOURCE)
17887
- - pattern: $SANITIZE. ... .$A($SOURCE)
17888
- - pattern: $A. ... .$SANITIZE($SOURCE)
17889
- - focus-metavariable: $SOURCE
17890
- - metavariable-regex:
17891
- metavariable: $A
17892
- regex: (?i)(.*valid|.*sanitiz)
17893
17683
  pattern-sinks:
17894
- - requires: (EXPRESS and not CLEAN) or (EXPRESSTS and not CLEAN)
17895
- patterns:
17684
+ - patterns:
17896
17685
  - pattern-either:
17897
17686
  - patterns:
17898
- - pattern-either:
17899
- - pattern: '"$HTMLSTR" + $EXPR'
17900
- - pattern: '"$HTMLSTR".concat(...)'
17901
- - pattern: util.format($HTMLSTR, ...)
17687
+ - pattern: '"$URLSTR" % ...'
17902
17688
  - metavariable-pattern:
17903
- metavariable: $HTMLSTR
17689
+ metavariable: $URLSTR
17904
17690
  language: generic
17905
- pattern: <$TAG ...
17691
+ patterns:
17692
+ - pattern-either:
17693
+ - pattern: $SCHEME://%s
17694
+ - pattern: $SCHEME://%r
17906
17695
  - patterns:
17907
- - pattern: |
17908
- `...`
17909
- - pattern-regex: |
17910
- .*<\w+.*
17911
- - id: kotlin.lang.security.ecb-cipher.ecb-cipher
17696
+ - pattern: '"$URLSTR".format(...)'
17697
+ - metavariable-pattern:
17698
+ metavariable: $URLSTR
17699
+ language: generic
17700
+ pattern: $SCHEME:// { ... }
17701
+ - patterns:
17702
+ - pattern: '"$URLSTR" + ...'
17703
+ - metavariable-regex:
17704
+ metavariable: $URLSTR
17705
+ regex: .*://$
17706
+ - patterns:
17707
+ - pattern: f"$URLSTR{...}..."
17708
+ - metavariable-regex:
17709
+ metavariable: $URLSTR
17710
+ regex: .*://$
17711
+ - patterns:
17712
+ - pattern-inside: |
17713
+ $URL = "$URLSTR"
17714
+ ...
17715
+ - pattern: $URL += ...
17716
+ - metavariable-regex:
17717
+ metavariable: $URLSTR
17718
+ regex: .*://$
17719
+ pattern-sources:
17720
+ - patterns:
17721
+ - pattern-either:
17722
+ - pattern: flask.request.$ANYTHING
17723
+ - patterns:
17724
+ - pattern-inside: |
17725
+ @$APP.route(...)
17726
+ def $FUNC(..., $ROUTEVAR, ...):
17727
+ ...
17728
+ - pattern: $ROUTEVAR
17729
+ severity: WARNING
17730
+ - id: go.lang.security.audit.md5-used-as-password.md5-used-as-password
17731
+ languages:
17732
+ - go
17733
+ severity: WARNING
17734
+ message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
17735
+ password hash because it can be cracked by an attacker in a short amount of time.
17736
+ Use a suitable password hashing function such as bcrypt. You can use the `golang.org/x/crypto/bcrypt`
17737
+ package.
17738
+ options:
17739
+ interfile: true
17912
17740
  metadata:
17913
- cwe:
17914
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17741
+ category: security
17742
+ technology:
17743
+ - md5
17744
+ references:
17745
+ - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
17746
+ - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
17747
+ - https://github.com/returntocorp/semgrep-rules/issues/1609
17748
+ - https://pkg.go.dev/golang.org/x/crypto/bcrypt
17915
17749
  owasp:
17916
17750
  - A03:2017 - Sensitive Data Exposure
17917
17751
  - A02:2021 - Cryptographic Failures
17918
17752
  - A04:2025 - Cryptographic Failures
17919
- source-rule-url: https://find-sec-bugs.github.io/bugs.htm#ECB_MODE
17920
- category: security
17921
- technology:
17922
- - kotlin
17923
- references:
17924
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
17753
+ cwe:
17754
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17755
+ confidence: MEDIUM
17925
17756
  subcategory:
17926
17757
  - vuln
17927
- likelihood: LOW
17758
+ likelihood: MEDIUM
17928
17759
  impact: MEDIUM
17929
- confidence: MEDIUM
17760
+ interfile: true
17930
17761
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17931
17762
  vulnerability_class:
17932
17763
  - Cryptographic Issues
17933
- source: https://semgrep.dev/r/kotlin.lang.security.ecb-cipher.ecb-cipher
17934
- shortlink: https://sg.run/DzLj
17764
+ source: https://semgrep.dev/r/go.lang.security.audit.md5-used-as-password.md5-used-as-password
17765
+ shortlink: https://sg.run/4eOE
17935
17766
  semgrep.dev:
17936
17767
  rule:
17937
- r_id: 14696
17938
- rv_id: 1263263
17939
- rule_id: DbU1Zd
17940
- version_id: YDTZexg
17941
- url: https://semgrep.dev/playground/r/YDTZexg/kotlin.lang.security.ecb-cipher.ecb-cipher
17942
- origin: community
17943
- message: Cipher in ECB mode is detected. ECB mode produces the same output for the
17944
- same input each time which allows an attacker to intercept and replay the data.
17945
- Further, ECB mode does not provide any integrity checking. See https://find-sec-bugs.github.io/bugs.htm#CIPHER_INTEGRITY.
17946
- severity: WARNING
17768
+ r_id: 14688
17769
+ rv_id: 1262938
17770
+ rule_id: 4bU1Wj
17771
+ version_id: nWT2L9r
17772
+ url: https://semgrep.dev/playground/r/nWT2L9r/go.lang.security.audit.md5-used-as-password.md5-used-as-password
17773
+ origin: community
17774
+ mode: taint
17775
+ pattern-sources:
17776
+ - patterns:
17777
+ - pattern-either:
17778
+ - pattern: md5.New
17779
+ - pattern: md5.Sum
17780
+ pattern-sinks:
17781
+ - patterns:
17782
+ - pattern: $FUNCTION(...)
17783
+ - metavariable-regex:
17784
+ metavariable: $FUNCTION
17785
+ regex: (?i)(.*password.*)
17786
+ - id: go.lang.security.injection.tainted-sql-string.tainted-sql-string
17947
17787
  languages:
17948
- - kt
17949
- patterns:
17950
- - pattern-either:
17951
- - pattern: |
17952
- val $VAR : Cipher = $CIPHER.getInstance($MODE)
17953
- - pattern: |
17954
- var $VAR : Cipher = $CIPHER.getInstance($MODE)
17955
- - pattern: |
17956
- val $VAR = $CIPHER.getInstance($MODE)
17957
- - pattern: |
17958
- var $VAR = $CIPHER.getInstance($MODE)
17959
- - metavariable-regex:
17960
- metavariable: $MODE
17961
- regex: .*ECB.*
17962
- - id: kotlin.lang.security.no-null-cipher.no-null-cipher
17963
- pattern: NullCipher(...)
17788
+ - go
17789
+ message: User data flows into this manually-constructed SQL string. User data can
17790
+ be safely inserted into SQL strings using prepared statements or an object-relational
17791
+ mapper (ORM). Manually-constructed SQL strings is a possible indicator of SQL
17792
+ injection, which could let an attacker steal or manipulate data from the database.
17793
+ Instead, use prepared statements (`db.Query("SELECT * FROM t WHERE id = ?", id)`)
17794
+ or a safe library.
17795
+ options:
17796
+ interfile: true
17964
17797
  metadata:
17965
17798
  cwe:
17966
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17799
+ - 'CWE-89: Improper Neutralization of Special Elements used in an SQL Command
17800
+ (''SQL Injection'')'
17967
17801
  owasp:
17968
- - A03:2017 - Sensitive Data Exposure
17969
- - A02:2021 - Cryptographic Failures
17970
- - A04:2025 - Cryptographic Failures
17971
- source-rule-url: https://find-sec-bugs.github.io/bugs.htm#NULL_CIPHER
17972
- asvs:
17973
- section: V6 Stored Cryptography Verification Requirements
17974
- control_id: 6.2.5 Insecure Algorithm
17975
- control_url: https://github.com/OWASP/ASVS/blob/master/4.0/en/0x14-V6-Cryptography.md#v62-algorithms
17976
- version: '4'
17802
+ - A01:2017 - Injection
17803
+ - A03:2021 - Injection
17804
+ - A05:2025 - Injection
17805
+ references:
17806
+ - https://golang.org/doc/database/sql-injection
17807
+ - https://www.stackhawk.com/blog/golang-sql-injection-guide-examples-and-prevention/
17977
17808
  category: security
17978
17809
  technology:
17979
- - kotlin
17980
- references:
17981
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
17810
+ - go
17811
+ confidence: HIGH
17812
+ cwe2022-top25: true
17813
+ cwe2021-top25: true
17982
17814
  subcategory:
17983
17815
  - vuln
17984
- likelihood: LOW
17816
+ likelihood: HIGH
17985
17817
  impact: MEDIUM
17986
- confidence: MEDIUM
17818
+ interfile: true
17987
17819
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17988
17820
  vulnerability_class:
17989
- - Cryptographic Issues
17990
- source: https://semgrep.dev/r/kotlin.lang.security.no-null-cipher.no-null-cipher
17991
- shortlink: https://sg.run/0ywb
17821
+ - SQL Injection
17822
+ source: https://semgrep.dev/r/go.lang.security.injection.tainted-sql-string.tainted-sql-string
17823
+ shortlink: https://sg.run/PbEq
17992
17824
  semgrep.dev:
17993
17825
  rule:
17994
- r_id: 14698
17995
- rv_id: 1263265
17996
- rule_id: 0oU2Yy
17997
- version_id: o5TbDPj
17998
- url: https://semgrep.dev/playground/r/o5TbDPj/kotlin.lang.security.no-null-cipher.no-null-cipher
17826
+ r_id: 14689
17827
+ rv_id: 1409388
17828
+ rule_id: PeUoqy
17829
+ version_id: nWTQ5qD
17830
+ url: https://semgrep.dev/playground/r/nWTQ5qD/go.lang.security.injection.tainted-sql-string.tainted-sql-string
17999
17831
  origin: community
18000
- message: 'NullCipher was detected. This will not encrypt anything; the cipher text
18001
- will be the same as the plain text. Use a valid, secure cipher: Cipher.getInstance("AES/CBC/PKCS7PADDING").
18002
- See https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions for
18003
- more information.'
18004
- severity: WARNING
18005
- languages:
18006
- - kt
18007
- - scala
18008
- - id: kotlin.lang.security.use-of-md5.use-of-md5
18009
- message: Detected MD5 hash algorithm which is considered insecure. MD5 is not collision
18010
- resistant and is therefore not suitable as a cryptographic signature. Use SHA256
18011
- or SHA3 instead.
17832
+ mode: taint
17833
+ severity: ERROR
17834
+ pattern-sources:
17835
+ - patterns:
17836
+ - pattern-either:
17837
+ - pattern: |
17838
+ ($REQUEST : *http.Request).$ANYTHING
17839
+ - pattern: |
17840
+ ($REQUEST : http.Request).$ANYTHING
17841
+ - metavariable-regex:
17842
+ metavariable: $ANYTHING
17843
+ regex: ^(BasicAuth|Body|Cookie|Cookies|Form|FormValue|GetBody|Host|MultipartReader|ParseForm|ParseMultipartForm|PostForm|PostFormValue|Referer|RequestURI|Trailer|TransferEncoding|UserAgent|URL)$
17844
+ pattern-sinks:
17845
+ - patterns:
17846
+ - pattern-either:
17847
+ - patterns:
17848
+ - pattern-either:
17849
+ - pattern: |
17850
+ "$SQLSTR" + ...
17851
+ - patterns:
17852
+ - pattern-inside: |
17853
+ $VAR = "$SQLSTR";
17854
+ ...
17855
+ - pattern: $VAR += ...
17856
+ - patterns:
17857
+ - pattern-inside: |
17858
+ var $SB strings.Builder
17859
+ ...
17860
+ - pattern-inside: |
17861
+ $SB.WriteString("$SQLSTR")
17862
+ ...
17863
+ $SB.String(...)
17864
+ - pattern: |
17865
+ $SB.WriteString(...)
17866
+ - metavariable-regex:
17867
+ metavariable: $SQLSTR
17868
+ regex: (?i)(select|delete|insert|create|update|alter|drop).*
17869
+ - patterns:
17870
+ - pattern-either:
17871
+ - pattern: fmt.Fprintf($F, "$SQLSTR", ...)
17872
+ - pattern: fmt.Sprintf("$SQLSTR", ...)
17873
+ - pattern: fmt.Printf("$SQLSTR", ...)
17874
+ - metavariable-regex:
17875
+ metavariable: $SQLSTR
17876
+ regex: \s*(?i)(select|delete|insert|create|update|alter|drop)\b.*%(v|s|q).*
17877
+ pattern-sanitizers:
17878
+ - pattern-either:
17879
+ - pattern: strconv.Atoi(...)
17880
+ - pattern: |
17881
+ ($X: bool)
17882
+ - id: java.lang.security.audit.md5-used-as-password.md5-used-as-password
18012
17883
  languages:
18013
- - kt
17884
+ - java
18014
17885
  severity: WARNING
17886
+ message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
17887
+ password hash because it can be cracked by an attacker in a short amount of time.
17888
+ Use a suitable password hashing function such as PBKDF2 or bcrypt. You can use
17889
+ `javax.crypto.SecretKeyFactory` with `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")`
17890
+ or, if using Spring, `org.springframework.security.crypto.bcrypt`.
18015
17891
  metadata:
17892
+ category: security
17893
+ technology:
17894
+ - java
17895
+ - md5
17896
+ references:
17897
+ - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
17898
+ - https://github.com/returntocorp/semgrep-rules/issues/1609
17899
+ - https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SecretKeyFactory
17900
+ - https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoder.html
18016
17901
  owasp:
18017
17902
  - A03:2017 - Sensitive Data Exposure
18018
17903
  - A02:2021 - Cryptographic Failures
18019
17904
  - A04:2025 - Cryptographic Failures
18020
17905
  cwe:
18021
- - 'CWE-328: Use of Weak Hash'
18022
- source-rule-url: https://find-sec-bugs.github.io/bugs.htm#WEAK_MESSAGE_DIGEST_MD5
18023
- category: security
18024
- technology:
18025
- - kotlin
18026
- references:
18027
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
17906
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
18028
17907
  subcategory:
18029
17908
  - vuln
18030
- likelihood: LOW
17909
+ likelihood: HIGH
18031
17910
  impact: MEDIUM
18032
17911
  confidence: MEDIUM
18033
17912
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18034
17913
  vulnerability_class:
18035
- - Insecure Hashing Algorithm
18036
- source: https://semgrep.dev/r/kotlin.lang.security.use-of-md5.use-of-md5
18037
- shortlink: https://sg.run/4eQx
17914
+ - Cryptographic Issues
17915
+ source: https://semgrep.dev/r/java.lang.security.audit.md5-used-as-password.md5-used-as-password
17916
+ shortlink: https://sg.run/JxEQ
18038
17917
  semgrep.dev:
18039
17918
  rule:
18040
- r_id: 14700
18041
- rv_id: 1263267
18042
- rule_id: qNUXPj
18043
- version_id: pZT03Jd
18044
- url: https://semgrep.dev/playground/r/pZT03Jd/kotlin.lang.security.use-of-md5.use-of-md5
17919
+ r_id: 14690
17920
+ rv_id: 1263029
17921
+ rule_id: JDULAW
17922
+ version_id: bZT53QB
17923
+ url: https://semgrep.dev/playground/r/bZT53QB/java.lang.security.audit.md5-used-as-password.md5-used-as-password
18045
17924
  origin: community
18046
- pattern-either:
18047
- - pattern: |
18048
- java.security.MessageDigest.getInstance("MD5")
18049
- - pattern: |
18050
- org.apache.commons.codec.digest.DigestUtils.getMd5Digest()
18051
- - id: python.flask.security.injection.tainted-sql-string.tainted-sql-string
18052
- message: Detected user input used to manually construct a SQL string. This is usually
18053
- bad practice because manual construction could accidentally result in a SQL injection.
18054
- An attacker could use a SQL injection to steal or modify contents of the database.
18055
- Instead, use a parameterized query which is available by default in most database
18056
- engines. Alternatively, consider using an object-relational mapper (ORM) such
18057
- as SQLAlchemy which will protect your queries.
17925
+ mode: taint
17926
+ pattern-sources:
17927
+ - patterns:
17928
+ - pattern-inside: |
17929
+ $TYPE $MD = MessageDigest.getInstance("MD5");
17930
+ ...
17931
+ - pattern: $MD.digest(...);
17932
+ pattern-sinks:
17933
+ - patterns:
17934
+ - pattern: $MODEL.$METHOD(...);
17935
+ - metavariable-regex:
17936
+ metavariable: $METHOD
17937
+ regex: (?i)(.*password.*)
17938
+ - id: javascript.express.security.injection.raw-html-format.raw-html-format
17939
+ message: User data flows into the host portion of this manually-constructed HTML.
17940
+ This can introduce a Cross-Site-Scripting (XSS) vulnerability if this comes from
17941
+ user-provided input. Consider using a sanitization library such as DOMPurify to
17942
+ sanitize the HTML within.
18058
17943
  metadata:
18059
17944
  cwe:
18060
- - 'CWE-704: Incorrect Type Conversion or Cast'
17945
+ - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
17946
+ Scripting'')'
18061
17947
  owasp:
18062
- - A01:2017 - Injection
17948
+ - A07:2017 - Cross-Site Scripting (XSS)
18063
17949
  - A03:2021 - Injection
18064
17950
  - A05:2025 - Injection
18065
17951
  references:
18066
- - https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-textual-sql
18067
- - https://www.tutorialspoint.com/sqlalchemy/sqlalchemy_quick_guide.htm
18068
- - https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-more-specific-text-with-table-expression-literal-column-and-expression-column
17952
+ - https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
18069
17953
  category: security
18070
17954
  technology:
18071
- - sqlalchemy
18072
- - flask
17955
+ - express
17956
+ cwe2022-top25: true
17957
+ cwe2021-top25: true
18073
17958
  subcategory:
18074
17959
  - vuln
17960
+ likelihood: HIGH
18075
17961
  impact: MEDIUM
18076
- likelihood: MEDIUM
18077
17962
  confidence: MEDIUM
18078
17963
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18079
17964
  vulnerability_class:
18080
- - Improper Validation
18081
- source: https://semgrep.dev/r/python.flask.security.injection.tainted-sql-string.tainted-sql-string
18082
- shortlink: https://sg.run/JxZj
17965
+ - Cross-Site-Scripting (XSS)
17966
+ source: https://semgrep.dev/r/javascript.express.security.injection.raw-html-format.raw-html-format
17967
+ shortlink: https://sg.run/5DO3
18083
17968
  semgrep.dev:
18084
17969
  rule:
18085
- r_id: 14702
18086
- rv_id: 1409402
18087
- rule_id: YGUDKQ
18088
- version_id: A8TEvb4
18089
- url: https://semgrep.dev/playground/r/A8TEvb4/python.flask.security.injection.tainted-sql-string.tainted-sql-string
18090
- origin: community
18091
- severity: ERROR
18092
- languages:
18093
- - python
17970
+ r_id: 14691
17971
+ rv_id: 1263175
17972
+ rule_id: 5rUL0X
17973
+ version_id: NdTzyQv
17974
+ url: https://semgrep.dev/playground/r/NdTzyQv/javascript.express.security.injection.raw-html-format.raw-html-format
17975
+ origin: community
17976
+ languages:
17977
+ - javascript
17978
+ - typescript
17979
+ severity: WARNING
18094
17980
  mode: taint
18095
17981
  pattern-sources:
18096
- - patterns:
17982
+ - label: EXPRESS
17983
+ patterns:
18097
17984
  - pattern-either:
18098
- - pattern: flask.request.$ANYTHING
17985
+ - pattern-inside: function ... ($REQ, $RES) {...}
17986
+ - pattern-inside: function ... ($REQ, $RES, $NEXT) {...}
18099
17987
  - patterns:
18100
- - pattern-inside: |
18101
- @$APP.route(...)
18102
- def $FUNC(..., $ROUTEVAR, ...):
18103
- ...
18104
- - pattern: $ROUTEVAR
18105
- pattern-sinks:
18106
- - patterns:
17988
+ - pattern-either:
17989
+ - pattern-inside: $APP.$METHOD(..., function $FUNC($REQ, $RES) {...})
17990
+ - pattern-inside: $APP.$METHOD(..., function $FUNC($REQ, $RES, $NEXT) {...})
17991
+ - metavariable-regex:
17992
+ metavariable: $METHOD
17993
+ regex: ^(get|post|put|head|delete|options)$
18107
17994
  - pattern-either:
18108
- - pattern: |
18109
- "$SQLSTR" + ...
18110
- - pattern: |
18111
- "$SQLSTR" % ...
18112
- - pattern: |
18113
- "$SQLSTR".format(...)
18114
- - pattern: |
18115
- f"$SQLSTR{...}..."
17995
+ - pattern: $REQ.query
17996
+ - pattern: $REQ.body
17997
+ - pattern: $REQ.params
17998
+ - pattern: $REQ.cookies
17999
+ - pattern: $REQ.headers
18000
+ - label: EXPRESSTS
18001
+ patterns:
18002
+ - pattern-either:
18003
+ - pattern-inside: |
18004
+ ({ $REQ }: Request,$RES: Response, $NEXT: NextFunction) =>
18005
+ {...}
18006
+ - pattern-inside: |
18007
+ ({ $REQ }: Request,$RES: Response) => {...}
18008
+ - focus-metavariable: $REQ
18009
+ - pattern-either:
18010
+ - pattern: params
18011
+ - pattern: query
18012
+ - pattern: cookies
18013
+ - pattern: headers
18014
+ - pattern: body
18015
+ - label: CLEAN
18016
+ by-side-effect: true
18017
+ patterns:
18018
+ - pattern-either:
18019
+ - pattern: $A($SOURCE)
18020
+ - pattern: $SANITIZE. ... .$A($SOURCE)
18021
+ - pattern: $A. ... .$SANITIZE($SOURCE)
18022
+ - focus-metavariable: $SOURCE
18116
18023
  - metavariable-regex:
18117
- metavariable: $SQLSTR
18118
- regex: \s*(?i)(select|delete|insert|create|update|alter|drop)\b.*
18119
- - id: python.lang.security.audit.md5-used-as-password.md5-used-as-password
18120
- severity: WARNING
18121
- message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
18122
- password hash because it can be cracked by an attacker in a short amount of time.
18123
- Use a suitable password hashing function such as scrypt. You can use `hashlib.scrypt`.
18124
- languages:
18125
- - python
18024
+ metavariable: $A
18025
+ regex: (?i)(.*valid|.*sanitiz)
18026
+ pattern-sinks:
18027
+ - requires: (EXPRESS and not CLEAN) or (EXPRESSTS and not CLEAN)
18028
+ patterns:
18029
+ - pattern-either:
18030
+ - patterns:
18031
+ - pattern-either:
18032
+ - pattern: '"$HTMLSTR" + $EXPR'
18033
+ - pattern: '"$HTMLSTR".concat(...)'
18034
+ - pattern: util.format($HTMLSTR, ...)
18035
+ - metavariable-pattern:
18036
+ metavariable: $HTMLSTR
18037
+ language: generic
18038
+ pattern: <$TAG ...
18039
+ - patterns:
18040
+ - pattern: |
18041
+ `...`
18042
+ - pattern-regex: |
18043
+ .*<\w+.*
18044
+ - id: kotlin.lang.security.ecb-cipher.ecb-cipher
18126
18045
  metadata:
18127
18046
  cwe:
18128
18047
  - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
@@ -18130,127 +18049,341 @@ rules:
18130
18049
  - A03:2017 - Sensitive Data Exposure
18131
18050
  - A02:2021 - Cryptographic Failures
18132
18051
  - A04:2025 - Cryptographic Failures
18133
- references:
18134
- - https://tools.ietf.org/html/rfc6151
18135
- - https://crypto.stackexchange.com/questions/44151/how-does-the-flame-malware-take-advantage-of-md5-collision
18136
- - https://pycryptodome.readthedocs.io/en/latest/src/hash/sha3_256.html
18137
- - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
18138
- - https://github.com/returntocorp/semgrep-rules/issues/1609
18139
- - https://docs.python.org/3/library/hashlib.html#hashlib.scrypt
18052
+ source-rule-url: https://find-sec-bugs.github.io/bugs.htm#ECB_MODE
18140
18053
  category: security
18141
18054
  technology:
18142
- - pycryptodome
18143
- - hashlib
18144
- - md5
18055
+ - kotlin
18056
+ references:
18057
+ - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
18145
18058
  subcategory:
18146
18059
  - vuln
18147
- likelihood: HIGH
18148
- impact: LOW
18060
+ likelihood: LOW
18061
+ impact: MEDIUM
18149
18062
  confidence: MEDIUM
18150
18063
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18151
18064
  vulnerability_class:
18152
18065
  - Cryptographic Issues
18153
- source: https://semgrep.dev/r/python.lang.security.audit.md5-used-as-password.md5-used-as-password
18154
- shortlink: https://sg.run/5DwD
18066
+ source: https://semgrep.dev/r/kotlin.lang.security.ecb-cipher.ecb-cipher
18067
+ shortlink: https://sg.run/DzLj
18155
18068
  semgrep.dev:
18156
18069
  rule:
18157
- r_id: 14703
18158
- rv_id: 1263504
18159
- rule_id: 6JU1w1
18160
- version_id: WrTqKDz
18161
- url: https://semgrep.dev/playground/r/WrTqKDz/python.lang.security.audit.md5-used-as-password.md5-used-as-password
18070
+ r_id: 14696
18071
+ rv_id: 1263263
18072
+ rule_id: DbU1Zd
18073
+ version_id: YDTZexg
18074
+ url: https://semgrep.dev/playground/r/YDTZexg/kotlin.lang.security.ecb-cipher.ecb-cipher
18162
18075
  origin: community
18163
- mode: taint
18164
- pattern-sources:
18165
- - patterns:
18166
- - pattern-either:
18167
- - pattern: hashlib.md5
18168
- - pattern: hashlib.new(..., name="MD5", ...)
18169
- - pattern: Cryptodome.Hash.MD5
18170
- - pattern: Crypto.Hash.MD5
18171
- - pattern: cryptography.hazmat.primitives.hashes.MD5
18172
- pattern-sinks:
18173
- - patterns:
18174
- - pattern: $FUNCTION(...)
18175
- - metavariable-regex:
18176
- metavariable: $FUNCTION
18177
- regex: (?i)(.*password.*)
18178
- - id: ruby.lang.security.md5-used-as-password.md5-used-as-password
18179
- languages:
18180
- - ruby
18076
+ message: Cipher in ECB mode is detected. ECB mode produces the same output for the
18077
+ same input each time which allows an attacker to intercept and replay the data.
18078
+ Further, ECB mode does not provide any integrity checking. See https://find-sec-bugs.github.io/bugs.htm#CIPHER_INTEGRITY.
18181
18079
  severity: WARNING
18182
- message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
18183
- password hash because it can be cracked by an attacker in a short amount of time.
18184
- Instead, use a suitable password hashing function such as bcrypt. You can use
18185
- the `bcrypt` gem.
18080
+ languages:
18081
+ - kt
18082
+ patterns:
18083
+ - pattern-either:
18084
+ - pattern: |
18085
+ val $VAR : Cipher = $CIPHER.getInstance($MODE)
18086
+ - pattern: |
18087
+ var $VAR : Cipher = $CIPHER.getInstance($MODE)
18088
+ - pattern: |
18089
+ val $VAR = $CIPHER.getInstance($MODE)
18090
+ - pattern: |
18091
+ var $VAR = $CIPHER.getInstance($MODE)
18092
+ - metavariable-regex:
18093
+ metavariable: $MODE
18094
+ regex: .*ECB.*
18095
+ - id: kotlin.lang.security.no-null-cipher.no-null-cipher
18096
+ pattern: NullCipher(...)
18186
18097
  metadata:
18187
- category: security
18188
- technology:
18189
- - md5
18190
- references:
18191
- - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
18192
- - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
18193
- - https://github.com/returntocorp/semgrep-rules/issues/1609
18098
+ cwe:
18099
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
18194
18100
  owasp:
18195
18101
  - A03:2017 - Sensitive Data Exposure
18196
18102
  - A02:2021 - Cryptographic Failures
18197
18103
  - A04:2025 - Cryptographic Failures
18198
- cwe:
18199
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
18104
+ source-rule-url: https://find-sec-bugs.github.io/bugs.htm#NULL_CIPHER
18105
+ asvs:
18106
+ section: V6 Stored Cryptography Verification Requirements
18107
+ control_id: 6.2.5 Insecure Algorithm
18108
+ control_url: https://github.com/OWASP/ASVS/blob/master/4.0/en/0x14-V6-Cryptography.md#v62-algorithms
18109
+ version: '4'
18110
+ category: security
18111
+ technology:
18112
+ - kotlin
18113
+ references:
18114
+ - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
18200
18115
  subcategory:
18201
18116
  - vuln
18202
- likelihood: HIGH
18117
+ likelihood: LOW
18203
18118
  impact: MEDIUM
18204
18119
  confidence: MEDIUM
18205
18120
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18206
18121
  vulnerability_class:
18207
18122
  - Cryptographic Issues
18208
- source: https://semgrep.dev/r/ruby.lang.security.md5-used-as-password.md5-used-as-password
18209
- shortlink: https://sg.run/GOZy
18123
+ source: https://semgrep.dev/r/kotlin.lang.security.no-null-cipher.no-null-cipher
18124
+ shortlink: https://sg.run/0ywb
18210
18125
  semgrep.dev:
18211
18126
  rule:
18212
- r_id: 14704
18213
- rv_id: 1263611
18214
- rule_id: oqU4p2
18215
- version_id: JdTzx0e
18216
- url: https://semgrep.dev/playground/r/JdTzx0e/ruby.lang.security.md5-used-as-password.md5-used-as-password
18127
+ r_id: 14698
18128
+ rv_id: 1263265
18129
+ rule_id: 0oU2Yy
18130
+ version_id: o5TbDPj
18131
+ url: https://semgrep.dev/playground/r/o5TbDPj/kotlin.lang.security.no-null-cipher.no-null-cipher
18217
18132
  origin: community
18218
- mode: taint
18219
- pattern-sources:
18220
- - pattern: Digest::MD5
18221
- pattern-sinks:
18222
- - patterns:
18223
- - pattern: $FUNCTION(...);
18224
- - metavariable-regex:
18225
- metavariable: $FUNCTION
18226
- regex: (?i)(.*password.*)
18227
- - id: ruby.rails.security.injection.tainted-url-host.tainted-url-host
18133
+ message: 'NullCipher was detected. This will not encrypt anything; the cipher text
18134
+ will be the same as the plain text. Use a valid, secure cipher: Cipher.getInstance("AES/CBC/PKCS7PADDING").
18135
+ See https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions for
18136
+ more information.'
18137
+ severity: WARNING
18228
18138
  languages:
18229
- - ruby
18139
+ - kt
18140
+ - scala
18141
+ - id: kotlin.lang.security.use-of-md5.use-of-md5
18142
+ message: Detected MD5 hash algorithm which is considered insecure. MD5 is not collision
18143
+ resistant and is therefore not suitable as a cryptographic signature. Use SHA256
18144
+ or SHA3 instead.
18145
+ languages:
18146
+ - kt
18230
18147
  severity: WARNING
18231
- message: User data flows into the host portion of this manually-constructed URL.
18232
- This could allow an attacker to send data to their own server, potentially exposing
18233
- sensitive data such as cookies or authorization information sent with this request.
18234
- They could also probe internal servers or other resources that the server running
18235
- this code can access. (This is called server-side request forgery, or SSRF.) Do
18236
- not allow arbitrary hosts. Use the `ssrf_filter` gem and guard the url construction
18237
- with `SsrfFilter(...)`, or create an allowlist for approved hosts.
18238
18148
  metadata:
18239
- cwe:
18240
- - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
18241
- Scripting'')'
18242
18149
  owasp:
18243
- - A07:2017 - Cross-Site Scripting (XSS)
18244
- - A03:2021 - Injection
18245
- - A05:2025 - Injection
18150
+ - A03:2017 - Sensitive Data Exposure
18151
+ - A02:2021 - Cryptographic Failures
18152
+ - A04:2025 - Cryptographic Failures
18153
+ cwe:
18154
+ - 'CWE-328: Use of Weak Hash'
18155
+ source-rule-url: https://find-sec-bugs.github.io/bugs.htm#WEAK_MESSAGE_DIGEST_MD5
18246
18156
  category: security
18247
18157
  technology:
18248
- - rails
18158
+ - kotlin
18249
18159
  references:
18250
- - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
18251
- - https://github.com/arkadiyt/ssrf_filter
18252
- cwe2022-top25: true
18253
- cwe2021-top25: true
18160
+ - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
18161
+ subcategory:
18162
+ - vuln
18163
+ likelihood: LOW
18164
+ impact: MEDIUM
18165
+ confidence: MEDIUM
18166
+ license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18167
+ vulnerability_class:
18168
+ - Insecure Hashing Algorithm
18169
+ source: https://semgrep.dev/r/kotlin.lang.security.use-of-md5.use-of-md5
18170
+ shortlink: https://sg.run/4eQx
18171
+ semgrep.dev:
18172
+ rule:
18173
+ r_id: 14700
18174
+ rv_id: 1263267
18175
+ rule_id: qNUXPj
18176
+ version_id: pZT03Jd
18177
+ url: https://semgrep.dev/playground/r/pZT03Jd/kotlin.lang.security.use-of-md5.use-of-md5
18178
+ origin: community
18179
+ pattern-either:
18180
+ - pattern: |
18181
+ java.security.MessageDigest.getInstance("MD5")
18182
+ - pattern: |
18183
+ org.apache.commons.codec.digest.DigestUtils.getMd5Digest()
18184
+ - id: python.flask.security.injection.tainted-sql-string.tainted-sql-string
18185
+ message: Detected user input used to manually construct a SQL string. This is usually
18186
+ bad practice because manual construction could accidentally result in a SQL injection.
18187
+ An attacker could use a SQL injection to steal or modify contents of the database.
18188
+ Instead, use a parameterized query which is available by default in most database
18189
+ engines. Alternatively, consider using an object-relational mapper (ORM) such
18190
+ as SQLAlchemy which will protect your queries.
18191
+ metadata:
18192
+ cwe:
18193
+ - 'CWE-704: Incorrect Type Conversion or Cast'
18194
+ owasp:
18195
+ - A01:2017 - Injection
18196
+ - A03:2021 - Injection
18197
+ - A05:2025 - Injection
18198
+ references:
18199
+ - https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-textual-sql
18200
+ - https://www.tutorialspoint.com/sqlalchemy/sqlalchemy_quick_guide.htm
18201
+ - https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-more-specific-text-with-table-expression-literal-column-and-expression-column
18202
+ category: security
18203
+ technology:
18204
+ - sqlalchemy
18205
+ - flask
18206
+ subcategory:
18207
+ - vuln
18208
+ impact: MEDIUM
18209
+ likelihood: MEDIUM
18210
+ confidence: MEDIUM
18211
+ license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18212
+ vulnerability_class:
18213
+ - Improper Validation
18214
+ source: https://semgrep.dev/r/python.flask.security.injection.tainted-sql-string.tainted-sql-string
18215
+ shortlink: https://sg.run/JxZj
18216
+ semgrep.dev:
18217
+ rule:
18218
+ r_id: 14702
18219
+ rv_id: 1409402
18220
+ rule_id: YGUDKQ
18221
+ version_id: A8TEvb4
18222
+ url: https://semgrep.dev/playground/r/A8TEvb4/python.flask.security.injection.tainted-sql-string.tainted-sql-string
18223
+ origin: community
18224
+ severity: ERROR
18225
+ languages:
18226
+ - python
18227
+ mode: taint
18228
+ pattern-sources:
18229
+ - patterns:
18230
+ - pattern-either:
18231
+ - pattern: flask.request.$ANYTHING
18232
+ - patterns:
18233
+ - pattern-inside: |
18234
+ @$APP.route(...)
18235
+ def $FUNC(..., $ROUTEVAR, ...):
18236
+ ...
18237
+ - pattern: $ROUTEVAR
18238
+ pattern-sinks:
18239
+ - patterns:
18240
+ - pattern-either:
18241
+ - pattern: |
18242
+ "$SQLSTR" + ...
18243
+ - pattern: |
18244
+ "$SQLSTR" % ...
18245
+ - pattern: |
18246
+ "$SQLSTR".format(...)
18247
+ - pattern: |
18248
+ f"$SQLSTR{...}..."
18249
+ - metavariable-regex:
18250
+ metavariable: $SQLSTR
18251
+ regex: \s*(?i)(select|delete|insert|create|update|alter|drop)\b.*
18252
+ - id: python.lang.security.audit.md5-used-as-password.md5-used-as-password
18253
+ severity: WARNING
18254
+ message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
18255
+ password hash because it can be cracked by an attacker in a short amount of time.
18256
+ Use a suitable password hashing function such as scrypt. You can use `hashlib.scrypt`.
18257
+ languages:
18258
+ - python
18259
+ metadata:
18260
+ cwe:
18261
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
18262
+ owasp:
18263
+ - A03:2017 - Sensitive Data Exposure
18264
+ - A02:2021 - Cryptographic Failures
18265
+ - A04:2025 - Cryptographic Failures
18266
+ references:
18267
+ - https://tools.ietf.org/html/rfc6151
18268
+ - https://crypto.stackexchange.com/questions/44151/how-does-the-flame-malware-take-advantage-of-md5-collision
18269
+ - https://pycryptodome.readthedocs.io/en/latest/src/hash/sha3_256.html
18270
+ - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
18271
+ - https://github.com/returntocorp/semgrep-rules/issues/1609
18272
+ - https://docs.python.org/3/library/hashlib.html#hashlib.scrypt
18273
+ category: security
18274
+ technology:
18275
+ - pycryptodome
18276
+ - hashlib
18277
+ - md5
18278
+ subcategory:
18279
+ - vuln
18280
+ likelihood: HIGH
18281
+ impact: LOW
18282
+ confidence: MEDIUM
18283
+ license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18284
+ vulnerability_class:
18285
+ - Cryptographic Issues
18286
+ source: https://semgrep.dev/r/python.lang.security.audit.md5-used-as-password.md5-used-as-password
18287
+ shortlink: https://sg.run/5DwD
18288
+ semgrep.dev:
18289
+ rule:
18290
+ r_id: 14703
18291
+ rv_id: 1263504
18292
+ rule_id: 6JU1w1
18293
+ version_id: WrTqKDz
18294
+ url: https://semgrep.dev/playground/r/WrTqKDz/python.lang.security.audit.md5-used-as-password.md5-used-as-password
18295
+ origin: community
18296
+ mode: taint
18297
+ pattern-sources:
18298
+ - patterns:
18299
+ - pattern-either:
18300
+ - pattern: hashlib.md5
18301
+ - pattern: hashlib.new(..., name="MD5", ...)
18302
+ - pattern: Cryptodome.Hash.MD5
18303
+ - pattern: Crypto.Hash.MD5
18304
+ - pattern: cryptography.hazmat.primitives.hashes.MD5
18305
+ pattern-sinks:
18306
+ - patterns:
18307
+ - pattern: $FUNCTION(...)
18308
+ - metavariable-regex:
18309
+ metavariable: $FUNCTION
18310
+ regex: (?i)(.*password.*)
18311
+ - id: ruby.lang.security.md5-used-as-password.md5-used-as-password
18312
+ languages:
18313
+ - ruby
18314
+ severity: WARNING
18315
+ message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
18316
+ password hash because it can be cracked by an attacker in a short amount of time.
18317
+ Instead, use a suitable password hashing function such as bcrypt. You can use
18318
+ the `bcrypt` gem.
18319
+ metadata:
18320
+ category: security
18321
+ technology:
18322
+ - md5
18323
+ references:
18324
+ - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
18325
+ - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
18326
+ - https://github.com/returntocorp/semgrep-rules/issues/1609
18327
+ owasp:
18328
+ - A03:2017 - Sensitive Data Exposure
18329
+ - A02:2021 - Cryptographic Failures
18330
+ - A04:2025 - Cryptographic Failures
18331
+ cwe:
18332
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
18333
+ subcategory:
18334
+ - vuln
18335
+ likelihood: HIGH
18336
+ impact: MEDIUM
18337
+ confidence: MEDIUM
18338
+ license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18339
+ vulnerability_class:
18340
+ - Cryptographic Issues
18341
+ source: https://semgrep.dev/r/ruby.lang.security.md5-used-as-password.md5-used-as-password
18342
+ shortlink: https://sg.run/GOZy
18343
+ semgrep.dev:
18344
+ rule:
18345
+ r_id: 14704
18346
+ rv_id: 1263611
18347
+ rule_id: oqU4p2
18348
+ version_id: JdTzx0e
18349
+ url: https://semgrep.dev/playground/r/JdTzx0e/ruby.lang.security.md5-used-as-password.md5-used-as-password
18350
+ origin: community
18351
+ mode: taint
18352
+ pattern-sources:
18353
+ - pattern: Digest::MD5
18354
+ pattern-sinks:
18355
+ - patterns:
18356
+ - pattern: $FUNCTION(...);
18357
+ - metavariable-regex:
18358
+ metavariable: $FUNCTION
18359
+ regex: (?i)(.*password.*)
18360
+ - id: ruby.rails.security.injection.tainted-url-host.tainted-url-host
18361
+ languages:
18362
+ - ruby
18363
+ severity: WARNING
18364
+ message: User data flows into the host portion of this manually-constructed URL.
18365
+ This could allow an attacker to send data to their own server, potentially exposing
18366
+ sensitive data such as cookies or authorization information sent with this request.
18367
+ They could also probe internal servers or other resources that the server running
18368
+ this code can access. (This is called server-side request forgery, or SSRF.) Do
18369
+ not allow arbitrary hosts. Use the `ssrf_filter` gem and guard the url construction
18370
+ with `SsrfFilter(...)`, or create an allowlist for approved hosts.
18371
+ metadata:
18372
+ cwe:
18373
+ - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
18374
+ Scripting'')'
18375
+ owasp:
18376
+ - A07:2017 - Cross-Site Scripting (XSS)
18377
+ - A03:2021 - Injection
18378
+ - A05:2025 - Injection
18379
+ category: security
18380
+ technology:
18381
+ - rails
18382
+ references:
18383
+ - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
18384
+ - https://github.com/arkadiyt/ssrf_filter
18385
+ cwe2022-top25: true
18386
+ cwe2021-top25: true
18254
18387
  subcategory:
18255
18388
  - vuln
18256
18389
  likelihood: MEDIUM
@@ -41152,30 +41285,20 @@ rules:
41152
41285
  - pattern-regex: \$\{\{\s*secrets\.
41153
41286
  - pattern-not-inside: 'jobs: ...'
41154
41287
  severity: WARNING
41155
- - id: ruby.rails.security.injection.raw-html-format.raw-html-format
41156
- languages:
41157
- - ruby
41158
- severity: WARNING
41159
- message: Detected user input flowing into a manually constructed HTML string. You
41160
- may be accidentally bypassing secure methods of rendering HTML by manually constructing
41161
- HTML and this could create a cross-site scripting vulnerability, which could let
41162
- attackers steal sensitive user data. Use the `render template` and make template
41163
- files which will safely render HTML instead, or inspect that the HTML is absolutely
41164
- rendered safely with a function like `sanitize`.
41288
+ - id: ruby.rails.security.audit.xss.avoid-render-dynamic-path.avoid-render-dynamic-path
41165
41289
  metadata:
41166
- cwe:
41167
- - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
41168
- Scripting'')'
41169
41290
  owasp:
41170
- - A07:2017 - Cross-Site Scripting (XSS)
41171
- - A03:2021 - Injection
41172
- - A05:2025 - Injection
41291
+ - A05:2017 - Broken Access Control
41292
+ - A01:2021 - Broken Access Control
41293
+ - A01:2025 - Broken Access Control
41294
+ cwe:
41295
+ - 'CWE-22: Improper Limitation of a Pathname to a Restricted Directory (''Path
41296
+ Traversal'')'
41297
+ references:
41298
+ - https://brakemanscanner.org/docs/warning_types/dynamic_render_paths/
41173
41299
  category: security
41174
41300
  technology:
41175
41301
  - rails
41176
- references:
41177
- - https://www.netsparker.com/blog/web-security/preventing-xss-ruby-on-rails-web-applications/
41178
- - https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html
41179
41302
  cwe2022-top25: true
41180
41303
  cwe2021-top25: true
41181
41304
  subcategory:
@@ -41185,235 +41308,112 @@ rules:
41185
41308
  confidence: MEDIUM
41186
41309
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
41187
41310
  vulnerability_class:
41188
- - Cross-Site-Scripting (XSS)
41189
- source: https://semgrep.dev/r/ruby.rails.security.injection.raw-html-format.raw-html-format
41190
- shortlink: https://sg.run/b2JQ
41311
+ - Path Traversal
41312
+ source: https://semgrep.dev/r/ruby.rails.security.audit.xss.avoid-render-dynamic-path.avoid-render-dynamic-path
41313
+ shortlink: https://sg.run/GO2n
41191
41314
  semgrep.dev:
41192
41315
  rule:
41193
- r_id: 14470
41194
- rv_id: 1409408
41195
- rule_id: kxUwZX
41196
- version_id: qkTvgYY
41197
- url: https://semgrep.dev/playground/r/qkTvgYY/ruby.rails.security.injection.raw-html-format.raw-html-format
41316
+ r_id: 13592
41317
+ rv_id: 1263635
41318
+ rule_id: 6JU1bL
41319
+ version_id: bZT53p0
41320
+ url: https://semgrep.dev/playground/r/bZT53p0/ruby.rails.security.audit.xss.avoid-render-dynamic-path.avoid-render-dynamic-path
41198
41321
  origin: community
41199
- mode: taint
41200
- pattern-sanitizers:
41201
- - pattern-either:
41202
- - pattern: sanitize(...)
41203
- - pattern: strip_tags(...)
41204
- pattern-sources:
41205
- - patterns:
41206
- - pattern-either:
41207
- - pattern: params
41208
- - pattern: request
41209
- pattern-sinks:
41210
- - patterns:
41211
- - pattern-either:
41212
- - patterns:
41213
- - pattern: |
41214
- $HTMLSTR
41215
- - pattern-regex: <\w+.*
41216
- - patterns:
41217
- - pattern-either:
41218
- - pattern: Kernel::sprintf("$HTMLSTR", ...)
41219
- - pattern: |
41220
- "$HTMLSTR" + $EXPR
41221
- - pattern: |
41222
- "$HTMLSTR" % $EXPR
41223
- - metavariable-pattern:
41224
- metavariable: $HTMLSTR
41225
- language: generic
41226
- pattern: <$TAG ...
41227
- - id: bash.curl.security.curl-eval.curl-eval
41228
- severity: WARNING
41322
+ message: Avoid rendering user input. It may be possible for a malicious user to
41323
+ input a path that lets them access a template they shouldn't. To prevent this,
41324
+ check dynamic template paths against a predefined allowlist to make sure it's
41325
+ an allowed template.
41229
41326
  languages:
41230
- - bash
41231
- message: Data is being eval'd from a `curl` command. An attacker with control of
41232
- the server in the `curl` command could inject malicious code into the `eval`,
41233
- resulting in a system comrpomise. Avoid eval'ing untrusted data if you can. If
41234
- you must do this, consider checking the SHA sum of the content returned by the
41235
- server to verify its integrity.
41236
- metadata:
41237
- owasp:
41238
- - A03:2021 - Injection
41239
- - A05:2025 - Injection
41240
- cwe:
41241
- - 'CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code
41242
- (''Eval Injection'')'
41243
- category: security
41244
- technology:
41245
- - bash
41246
- - curl
41247
- confidence: MEDIUM
41248
- references:
41249
- - https://owasp.org/Top10/A03_2021-Injection
41250
- subcategory:
41251
- - vuln
41252
- likelihood: MEDIUM
41253
- impact: MEDIUM
41254
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
41255
- vulnerability_class:
41256
- - Code Injection
41257
- source: https://semgrep.dev/r/bash.curl.security.curl-eval.curl-eval
41258
- shortlink: https://sg.run/0yqJ
41259
- semgrep.dev:
41260
- rule:
41261
- r_id: 14554
41262
- rv_id: 1262601
41263
- rule_id: KxU7Rq
41264
- version_id: JdTzxL2
41265
- url: https://semgrep.dev/playground/r/JdTzxL2/bash.curl.security.curl-eval.curl-eval
41266
- origin: community
41327
+ - ruby
41328
+ severity: WARNING
41267
41329
  mode: taint
41268
41330
  pattern-sources:
41269
- - pattern: |
41270
- $(curl ...)
41271
- - pattern: |
41272
- `curl ...`
41331
+ - pattern: params
41332
+ - pattern: cookies
41333
+ - pattern: request.env
41273
41334
  pattern-sinks:
41274
- - pattern: eval ...
41275
- - id: python.flask.security.injection.tainted-url-host.tainted-url-host
41335
+ - patterns:
41336
+ - pattern-inside: render($X => $INPUT, ...)
41337
+ - pattern: $INPUT
41338
+ - metavariable-pattern:
41339
+ metavariable: $X
41340
+ pattern-either:
41341
+ - pattern: action
41342
+ - pattern: template
41343
+ - pattern: partial
41344
+ - pattern: file
41345
+ - id: python.lang.security.audit.insecure-file-permissions.insecure-file-permissions
41276
41346
  languages:
41277
41347
  - python
41278
- message: User data flows into the host portion of this manually-constructed URL.
41279
- This could allow an attacker to send data to their own server, potentially exposing
41280
- sensitive data such as cookies or authorization information sent with this request.
41281
- They could also probe internal servers or other resources that the server running
41282
- this code can access. (This is called server-side request forgery, or SSRF.) Do
41283
- not allow arbitrary hosts. Instead, create an allowlist for approved hosts, or
41284
- hardcode the correct host.
41348
+ severity: WARNING
41285
41349
  metadata:
41286
- cwe:
41287
- - 'CWE-918: Server-Side Request Forgery (SSRF)'
41350
+ category: security
41288
41351
  owasp:
41289
- - A10:2021 - Server-Side Request Forgery (SSRF)
41352
+ - A01:2021 - Broken Access Control
41290
41353
  - A01:2025 - Broken Access Control
41291
- references:
41292
- - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
41293
- category: security
41354
+ cwe:
41355
+ - 'CWE-276: Incorrect Default Permissions'
41294
41356
  technology:
41295
- - flask
41357
+ - python
41358
+ references:
41359
+ - https://owasp.org/Top10/A01_2021-Broken_Access_Control
41296
41360
  cwe2022-top25: true
41297
41361
  cwe2021-top25: true
41298
41362
  subcategory:
41299
41363
  - vuln
41364
+ likelihood: LOW
41300
41365
  impact: MEDIUM
41301
- likelihood: MEDIUM
41302
- confidence: MEDIUM
41303
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
41304
- vulnerability_class:
41305
- - Server-Side Request Forgery (SSRF)
41306
- source: https://semgrep.dev/r/python.flask.security.injection.tainted-url-host.tainted-url-host
41307
- shortlink: https://sg.run/RXpK
41308
- semgrep.dev:
41309
- rule:
41310
- r_id: 14649
41311
- rv_id: 1409403
41312
- rule_id: ReU3Wb
41313
- version_id: BjTy42w
41314
- url: https://semgrep.dev/playground/r/BjTy42w/python.flask.security.injection.tainted-url-host.tainted-url-host
41315
- origin: community
41316
- mode: taint
41317
- pattern-sinks:
41318
- - patterns:
41319
- - pattern-either:
41320
- - patterns:
41321
- - pattern: '"$URLSTR" % ...'
41322
- - metavariable-pattern:
41323
- metavariable: $URLSTR
41324
- language: generic
41325
- patterns:
41326
- - pattern-either:
41327
- - pattern: $SCHEME://%s
41328
- - pattern: $SCHEME://%r
41329
- - patterns:
41330
- - pattern: '"$URLSTR".format(...)'
41331
- - metavariable-pattern:
41332
- metavariable: $URLSTR
41333
- language: generic
41334
- pattern: $SCHEME:// { ... }
41335
- - patterns:
41336
- - pattern: '"$URLSTR" + ...'
41337
- - metavariable-regex:
41338
- metavariable: $URLSTR
41339
- regex: .*://$
41340
- - patterns:
41341
- - pattern: f"$URLSTR{...}..."
41342
- - metavariable-regex:
41343
- metavariable: $URLSTR
41344
- regex: .*://$
41345
- - patterns:
41346
- - pattern-inside: |
41347
- $URL = "$URLSTR"
41348
- ...
41349
- - pattern: $URL += ...
41350
- - metavariable-regex:
41351
- metavariable: $URLSTR
41352
- regex: .*://$
41353
- pattern-sources:
41354
- - patterns:
41355
- - pattern-either:
41356
- - pattern: flask.request.$ANYTHING
41357
- - patterns:
41358
- - pattern-inside: |
41359
- @$APP.route(...)
41360
- def $FUNC(..., $ROUTEVAR, ...):
41361
- ...
41362
- - pattern: $ROUTEVAR
41363
- severity: WARNING
41364
- - id: go.lang.security.audit.md5-used-as-password.md5-used-as-password
41365
- languages:
41366
- - go
41367
- severity: WARNING
41368
- message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
41369
- password hash because it can be cracked by an attacker in a short amount of time.
41370
- Use a suitable password hashing function such as bcrypt. You can use the `golang.org/x/crypto/bcrypt`
41371
- package.
41372
- options:
41373
- interfile: true
41374
- metadata:
41375
- category: security
41376
- technology:
41377
- - md5
41378
- references:
41379
- - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
41380
- - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
41381
- - https://github.com/returntocorp/semgrep-rules/issues/1609
41382
- - https://pkg.go.dev/golang.org/x/crypto/bcrypt
41383
- owasp:
41384
- - A03:2017 - Sensitive Data Exposure
41385
- - A02:2021 - Cryptographic Failures
41386
- - A04:2025 - Cryptographic Failures
41387
- cwe:
41388
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
41389
41366
  confidence: MEDIUM
41390
- subcategory:
41391
- - vuln
41392
- likelihood: MEDIUM
41393
- impact: MEDIUM
41394
- interfile: true
41395
41367
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
41396
41368
  vulnerability_class:
41397
- - Cryptographic Issues
41398
- source: https://semgrep.dev/r/go.lang.security.audit.md5-used-as-password.md5-used-as-password
41399
- shortlink: https://sg.run/4eOE
41369
+ - Improper Authorization
41370
+ source: https://semgrep.dev/r/python.lang.security.audit.insecure-file-permissions.insecure-file-permissions
41371
+ shortlink: https://sg.run/AXY4
41400
41372
  semgrep.dev:
41401
41373
  rule:
41402
- r_id: 14688
41403
- rv_id: 1262938
41404
- rule_id: 4bU1Wj
41405
- version_id: nWT2L9r
41406
- url: https://semgrep.dev/playground/r/nWT2L9r/go.lang.security.audit.md5-used-as-password.md5-used-as-password
41374
+ r_id: 13594
41375
+ rv_id: 1263482
41376
+ rule_id: zdUYqR
41377
+ version_id: O9Tpxqr
41378
+ url: https://semgrep.dev/playground/r/O9Tpxqr/python.lang.security.audit.insecure-file-permissions.insecure-file-permissions
41407
41379
  origin: community
41408
- mode: taint
41409
- pattern-sources:
41410
- - patterns:
41411
- - pattern-either:
41412
- - pattern: md5.New
41413
- - pattern: md5.Sum
41414
- pattern-sinks:
41415
- - patterns:
41416
- - pattern: $FUNCTION(...)
41417
- - metavariable-regex:
41418
- metavariable: $FUNCTION
41419
- regex: (?i)(.*password.*)
41380
+ message: These permissions `$BITS` are widely permissive and grant access to more
41381
+ people than may be necessary. A good default is `0o644` which gives read and write
41382
+ access to yourself and read access to everyone else.
41383
+ patterns:
41384
+ - pattern-inside: os.$METHOD(...)
41385
+ - metavariable-pattern:
41386
+ metavariable: $METHOD
41387
+ patterns:
41388
+ - pattern-either:
41389
+ - pattern: chmod
41390
+ - pattern: lchmod
41391
+ - pattern: fchmod
41392
+ - pattern-either:
41393
+ - patterns:
41394
+ - pattern: os.$METHOD($FILE, $BITS, ...)
41395
+ - metavariable-comparison:
41396
+ metavariable: $BITS
41397
+ comparison: $BITS >= 0o650 and $BITS < 0o100000
41398
+ - patterns:
41399
+ - pattern: os.$METHOD($FILE, $BITS)
41400
+ - metavariable-comparison:
41401
+ metavariable: $BITS
41402
+ comparison: $BITS >= 0o100650
41403
+ - patterns:
41404
+ - pattern: os.$METHOD($FILE, $BITS, ...)
41405
+ - metavariable-pattern:
41406
+ metavariable: $BITS
41407
+ patterns:
41408
+ - pattern-either:
41409
+ - pattern: <... stat.S_IWGRP ...>
41410
+ - pattern: <... stat.S_IXGRP ...>
41411
+ - pattern: <... stat.S_IWOTH ...>
41412
+ - pattern: <... stat.S_IXOTH ...>
41413
+ - pattern: <... stat.S_IRWXO ...>
41414
+ - pattern: <... stat.S_IRWXG ...>
41415
+ - patterns:
41416
+ - pattern: os.$METHOD($FILE, $EXPR | $MOD, ...)
41417
+ - metavariable-comparison:
41418
+ metavariable: $MOD
41419
+ comparison: $MOD == 0o111