codesentry-semgrep-rules 0.1.9 → 0.1.11

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
@@ -17179,6 +17179,81 @@ rules:
17179
17179
  - pattern: template
17180
17180
  - pattern: partial
17181
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
17182
17257
  - id: php.doctrine.security.audit.doctrine-orm-dangerous-query.doctrine-orm-dangerous-query
17183
17258
  languages:
17184
17259
  - php
@@ -17575,725 +17650,460 @@ rules:
17575
17650
  metavariable: $HTMLSTR
17576
17651
  language: generic
17577
17652
  pattern: <$TAG ...
17578
- - id: ruby.rails.security.injection.raw-html-format.raw-html-format
17653
+ - id: go.lang.security.injection.tainted-sql-string.tainted-sql-string
17579
17654
  languages:
17580
- - ruby
17581
- severity: WARNING
17582
- message: Detected user input flowing into a manually constructed HTML string. You
17583
- may be accidentally bypassing secure methods of rendering HTML by manually constructing
17584
- HTML and this could create a cross-site scripting vulnerability, which could let
17585
- attackers steal sensitive user data. Use the `render template` and make template
17586
- files which will safely render HTML instead, or inspect that the HTML is absolutely
17587
- rendered safely with a function like `sanitize`.
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
17588
17664
  metadata:
17589
17665
  cwe:
17590
- - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
17591
- Scripting'')'
17666
+ - 'CWE-89: Improper Neutralization of Special Elements used in an SQL Command
17667
+ (''SQL Injection'')'
17592
17668
  owasp:
17593
- - A07:2017 - Cross-Site Scripting (XSS)
17669
+ - A01:2017 - Injection
17594
17670
  - A03:2021 - Injection
17595
17671
  - 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/
17596
17675
  category: security
17597
17676
  technology:
17598
- - rails
17599
- references:
17600
- - https://www.netsparker.com/blog/web-security/preventing-xss-ruby-on-rails-web-applications/
17601
- - https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html
17677
+ - go
17678
+ confidence: HIGH
17602
17679
  cwe2022-top25: true
17603
17680
  cwe2021-top25: true
17604
17681
  subcategory:
17605
17682
  - vuln
17606
17683
  likelihood: HIGH
17607
17684
  impact: MEDIUM
17608
- confidence: MEDIUM
17685
+ interfile: true
17609
17686
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17610
17687
  vulnerability_class:
17611
- - Cross-Site-Scripting (XSS)
17612
- source: https://semgrep.dev/r/ruby.rails.security.injection.raw-html-format.raw-html-format
17613
- shortlink: https://sg.run/b2JQ
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
17614
17691
  semgrep.dev:
17615
17692
  rule:
17616
- r_id: 14470
17617
- rv_id: 1409408
17618
- rule_id: kxUwZX
17619
- version_id: qkTvgYY
17620
- url: https://semgrep.dev/playground/r/qkTvgYY/ruby.rails.security.injection.raw-html-format.raw-html-format
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
17621
17698
  origin: community
17622
17699
  mode: taint
17623
- pattern-sanitizers:
17624
- - pattern-either:
17625
- - pattern: sanitize(...)
17626
- - pattern: strip_tags(...)
17700
+ severity: ERROR
17627
17701
  pattern-sources:
17628
17702
  - patterns:
17629
17703
  - pattern-either:
17630
- - pattern: params
17631
- - pattern: request
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)$
17632
17711
  pattern-sinks:
17633
17712
  - patterns:
17634
17713
  - pattern-either:
17635
- - patterns:
17636
- - pattern: |
17637
- $HTMLSTR
17638
- - pattern-regex: <\w+.*
17639
17714
  - patterns:
17640
17715
  - pattern-either:
17641
- - pattern: Kernel::sprintf("$HTMLSTR", ...)
17642
- - pattern: |
17643
- "$HTMLSTR" + $EXPR
17644
17716
  - pattern: |
17645
- "$HTMLSTR" % $EXPR
17646
- - metavariable-pattern:
17647
- metavariable: $HTMLSTR
17648
- language: generic
17649
- pattern: <$TAG ...
17650
- - id: bash.curl.security.curl-eval.curl-eval
17651
- severity: WARNING
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).*
17736
+ - patterns:
17737
+ - 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
17652
17750
  languages:
17653
- - bash
17654
- message: Data is being eval'd from a `curl` command. An attacker with control of
17655
- the server in the `curl` command could inject malicious code into the `eval`,
17656
- resulting in a system comrpomise. Avoid eval'ing untrusted data if you can. If
17657
- you must do this, consider checking the SHA sum of the content returned by the
17658
- server to verify its integrity.
17751
+ - java
17752
+ 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`.
17659
17758
  metadata:
17660
- owasp:
17661
- - A03:2021 - Injection
17662
- - A05:2025 - Injection
17663
- cwe:
17664
- - 'CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code
17665
- (''Eval Injection'')'
17666
17759
  category: security
17667
17760
  technology:
17668
- - bash
17669
- - curl
17670
- confidence: MEDIUM
17761
+ - java
17762
+ - md5
17671
17763
  references:
17672
- - https://owasp.org/Top10/A03_2021-Injection
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
17768
+ owasp:
17769
+ - A03:2017 - Sensitive Data Exposure
17770
+ - A02:2021 - Cryptographic Failures
17771
+ - A04:2025 - Cryptographic Failures
17772
+ cwe:
17773
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17673
17774
  subcategory:
17674
17775
  - vuln
17675
- likelihood: MEDIUM
17776
+ likelihood: HIGH
17676
17777
  impact: MEDIUM
17778
+ confidence: MEDIUM
17677
17779
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17678
17780
  vulnerability_class:
17679
- - Code Injection
17680
- source: https://semgrep.dev/r/bash.curl.security.curl-eval.curl-eval
17681
- shortlink: https://sg.run/0yqJ
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
17682
17784
  semgrep.dev:
17683
17785
  rule:
17684
- r_id: 14554
17685
- rv_id: 1262601
17686
- rule_id: KxU7Rq
17687
- version_id: JdTzxL2
17688
- url: https://semgrep.dev/playground/r/JdTzxL2/bash.curl.security.curl-eval.curl-eval
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
17689
17791
  origin: community
17690
17792
  mode: taint
17691
17793
  pattern-sources:
17692
- - pattern: |
17693
- $(curl ...)
17694
- - pattern: |
17695
- `curl ...`
17794
+ - patterns:
17795
+ - pattern-inside: |
17796
+ $TYPE $MD = MessageDigest.getInstance("MD5");
17797
+ ...
17798
+ - pattern: $MD.digest(...);
17696
17799
  pattern-sinks:
17697
- - pattern: eval ...
17698
- - id: python.flask.security.injection.tainted-url-host.tainted-url-host
17699
- languages:
17700
- - python
17701
- message: User data flows into the host portion of this manually-constructed URL.
17702
- This could allow an attacker to send data to their own server, potentially exposing
17703
- sensitive data such as cookies or authorization information sent with this request.
17704
- They could also probe internal servers or other resources that the server running
17705
- this code can access. (This is called server-side request forgery, or SSRF.) Do
17706
- not allow arbitrary hosts. Instead, create an allowlist for approved hosts, or
17707
- hardcode the correct host.
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.
17708
17810
  metadata:
17709
17811
  cwe:
17710
- - 'CWE-918: Server-Side Request Forgery (SSRF)'
17812
+ - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
17813
+ Scripting'')'
17711
17814
  owasp:
17712
- - A10:2021 - Server-Side Request Forgery (SSRF)
17713
- - A01:2025 - Broken Access Control
17815
+ - A07:2017 - Cross-Site Scripting (XSS)
17816
+ - A03:2021 - Injection
17817
+ - A05:2025 - Injection
17714
17818
  references:
17715
- - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
17819
+ - https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
17716
17820
  category: security
17717
17821
  technology:
17718
- - flask
17822
+ - express
17719
17823
  cwe2022-top25: true
17720
17824
  cwe2021-top25: true
17721
17825
  subcategory:
17722
17826
  - vuln
17827
+ likelihood: HIGH
17723
17828
  impact: MEDIUM
17724
- likelihood: MEDIUM
17725
17829
  confidence: MEDIUM
17726
17830
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17727
17831
  vulnerability_class:
17728
- - Server-Side Request Forgery (SSRF)
17729
- source: https://semgrep.dev/r/python.flask.security.injection.tainted-url-host.tainted-url-host
17730
- shortlink: https://sg.run/RXpK
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
17731
17835
  semgrep.dev:
17732
17836
  rule:
17733
- r_id: 14649
17734
- rv_id: 1409403
17735
- rule_id: ReU3Wb
17736
- version_id: BjTy42w
17737
- url: https://semgrep.dev/playground/r/BjTy42w/python.flask.security.injection.tainted-url-host.tainted-url-host
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
17738
17842
  origin: community
17843
+ languages:
17844
+ - javascript
17845
+ - typescript
17846
+ severity: WARNING
17739
17847
  mode: taint
17740
- pattern-sinks:
17741
- - patterns:
17848
+ pattern-sources:
17849
+ - label: EXPRESS
17850
+ patterns:
17742
17851
  - pattern-either:
17852
+ - pattern-inside: function ... ($REQ, $RES) {...}
17853
+ - pattern-inside: function ... ($REQ, $RES, $NEXT) {...}
17743
17854
  - patterns:
17744
- - pattern: '"$URLSTR" % ...'
17745
- - metavariable-pattern:
17746
- metavariable: $URLSTR
17747
- language: generic
17748
- patterns:
17749
- - pattern-either:
17750
- - pattern: $SCHEME://%s
17751
- - pattern: $SCHEME://%r
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
+ pattern-sinks:
17894
+ - requires: (EXPRESS and not CLEAN) or (EXPRESSTS and not CLEAN)
17895
+ patterns:
17896
+ - pattern-either:
17752
17897
  - patterns:
17753
- - pattern: '"$URLSTR".format(...)'
17898
+ - pattern-either:
17899
+ - pattern: '"$HTMLSTR" + $EXPR'
17900
+ - pattern: '"$HTMLSTR".concat(...)'
17901
+ - pattern: util.format($HTMLSTR, ...)
17754
17902
  - metavariable-pattern:
17755
- metavariable: $URLSTR
17903
+ metavariable: $HTMLSTR
17756
17904
  language: generic
17757
- pattern: $SCHEME:// { ... }
17758
- - patterns:
17759
- - pattern: '"$URLSTR" + ...'
17760
- - metavariable-regex:
17761
- metavariable: $URLSTR
17762
- regex: .*://$
17763
- - patterns:
17764
- - pattern: f"$URLSTR{...}..."
17765
- - metavariable-regex:
17766
- metavariable: $URLSTR
17767
- regex: .*://$
17768
- - patterns:
17769
- - pattern-inside: |
17770
- $URL = "$URLSTR"
17771
- ...
17772
- - pattern: $URL += ...
17773
- - metavariable-regex:
17774
- metavariable: $URLSTR
17775
- regex: .*://$
17776
- pattern-sources:
17777
- - patterns:
17778
- - pattern-either:
17779
- - pattern: flask.request.$ANYTHING
17905
+ pattern: <$TAG ...
17780
17906
  - patterns:
17781
- - pattern-inside: |
17782
- @$APP.route(...)
17783
- def $FUNC(..., $ROUTEVAR, ...):
17784
- ...
17785
- - pattern: $ROUTEVAR
17786
- severity: WARNING
17787
- - id: go.lang.security.audit.md5-used-as-password.md5-used-as-password
17788
- languages:
17789
- - go
17790
- severity: WARNING
17791
- message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
17792
- password hash because it can be cracked by an attacker in a short amount of time.
17793
- Use a suitable password hashing function such as bcrypt. You can use the `golang.org/x/crypto/bcrypt`
17794
- package.
17795
- options:
17796
- interfile: true
17907
+ - pattern: |
17908
+ `...`
17909
+ - pattern-regex: |
17910
+ .*<\w+.*
17911
+ - id: kotlin.lang.security.ecb-cipher.ecb-cipher
17797
17912
  metadata:
17798
- category: security
17799
- technology:
17800
- - md5
17801
- references:
17802
- - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
17803
- - https://security.stackexchange.com/questions/211/how-to-securely-hash-passwords
17804
- - https://github.com/returntocorp/semgrep-rules/issues/1609
17805
- - https://pkg.go.dev/golang.org/x/crypto/bcrypt
17913
+ cwe:
17914
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17806
17915
  owasp:
17807
17916
  - A03:2017 - Sensitive Data Exposure
17808
17917
  - A02:2021 - Cryptographic Failures
17809
17918
  - A04:2025 - Cryptographic Failures
17810
- cwe:
17811
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17812
- confidence: MEDIUM
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
17813
17925
  subcategory:
17814
17926
  - vuln
17815
- likelihood: MEDIUM
17927
+ likelihood: LOW
17816
17928
  impact: MEDIUM
17817
- interfile: true
17929
+ confidence: MEDIUM
17818
17930
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17819
17931
  vulnerability_class:
17820
17932
  - Cryptographic Issues
17821
- source: https://semgrep.dev/r/go.lang.security.audit.md5-used-as-password.md5-used-as-password
17822
- shortlink: https://sg.run/4eOE
17933
+ source: https://semgrep.dev/r/kotlin.lang.security.ecb-cipher.ecb-cipher
17934
+ shortlink: https://sg.run/DzLj
17823
17935
  semgrep.dev:
17824
17936
  rule:
17825
- r_id: 14688
17826
- rv_id: 1262938
17827
- rule_id: 4bU1Wj
17828
- version_id: nWT2L9r
17829
- url: https://semgrep.dev/playground/r/nWT2L9r/go.lang.security.audit.md5-used-as-password.md5-used-as-password
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
17830
17942
  origin: community
17831
- mode: taint
17832
- pattern-sources:
17833
- - patterns:
17834
- - pattern-either:
17835
- - pattern: md5.New
17836
- - pattern: md5.Sum
17837
- pattern-sinks:
17838
- - patterns:
17839
- - pattern: $FUNCTION(...)
17840
- - metavariable-regex:
17841
- metavariable: $FUNCTION
17842
- regex: (?i)(.*password.*)
17843
- - id: go.lang.security.injection.tainted-sql-string.tainted-sql-string
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
17844
17947
  languages:
17845
- - go
17846
- message: User data flows into this manually-constructed SQL string. User data can
17847
- be safely inserted into SQL strings using prepared statements or an object-relational
17848
- mapper (ORM). Manually-constructed SQL strings is a possible indicator of SQL
17849
- injection, which could let an attacker steal or manipulate data from the database.
17850
- Instead, use prepared statements (`db.Query("SELECT * FROM t WHERE id = ?", id)`)
17851
- or a safe library.
17852
- options:
17853
- interfile: true
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(...)
17854
17964
  metadata:
17855
17965
  cwe:
17856
- - 'CWE-89: Improper Neutralization of Special Elements used in an SQL Command
17857
- (''SQL Injection'')'
17966
+ - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
17858
17967
  owasp:
17859
- - A01:2017 - Injection
17860
- - A03:2021 - Injection
17861
- - A05:2025 - Injection
17862
- references:
17863
- - https://golang.org/doc/database/sql-injection
17864
- - https://www.stackhawk.com/blog/golang-sql-injection-guide-examples-and-prevention/
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'
17865
17977
  category: security
17866
17978
  technology:
17867
- - go
17868
- confidence: HIGH
17869
- cwe2022-top25: true
17870
- cwe2021-top25: true
17979
+ - kotlin
17980
+ references:
17981
+ - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
17871
17982
  subcategory:
17872
17983
  - vuln
17873
- likelihood: HIGH
17984
+ likelihood: LOW
17874
17985
  impact: MEDIUM
17875
- interfile: true
17986
+ confidence: MEDIUM
17876
17987
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17877
17988
  vulnerability_class:
17878
- - SQL Injection
17879
- source: https://semgrep.dev/r/go.lang.security.injection.tainted-sql-string.tainted-sql-string
17880
- shortlink: https://sg.run/PbEq
17989
+ - Cryptographic Issues
17990
+ source: https://semgrep.dev/r/kotlin.lang.security.no-null-cipher.no-null-cipher
17991
+ shortlink: https://sg.run/0ywb
17881
17992
  semgrep.dev:
17882
17993
  rule:
17883
- r_id: 14689
17884
- rv_id: 1409388
17885
- rule_id: PeUoqy
17886
- version_id: nWTQ5qD
17887
- url: https://semgrep.dev/playground/r/nWTQ5qD/go.lang.security.injection.tainted-sql-string.tainted-sql-string
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
17888
17999
  origin: community
17889
- mode: taint
17890
- severity: ERROR
17891
- pattern-sources:
17892
- - patterns:
17893
- - pattern-either:
17894
- - pattern: |
17895
- ($REQUEST : *http.Request).$ANYTHING
17896
- - pattern: |
17897
- ($REQUEST : http.Request).$ANYTHING
17898
- - metavariable-regex:
17899
- metavariable: $ANYTHING
17900
- regex: ^(BasicAuth|Body|Cookie|Cookies|Form|FormValue|GetBody|Host|MultipartReader|ParseForm|ParseMultipartForm|PostForm|PostFormValue|Referer|RequestURI|Trailer|TransferEncoding|UserAgent|URL)$
17901
- pattern-sinks:
17902
- - patterns:
17903
- - pattern-either:
17904
- - patterns:
17905
- - pattern-either:
17906
- - pattern: |
17907
- "$SQLSTR" + ...
17908
- - patterns:
17909
- - pattern-inside: |
17910
- $VAR = "$SQLSTR";
17911
- ...
17912
- - pattern: $VAR += ...
17913
- - patterns:
17914
- - pattern-inside: |
17915
- var $SB strings.Builder
17916
- ...
17917
- - pattern-inside: |
17918
- $SB.WriteString("$SQLSTR")
17919
- ...
17920
- $SB.String(...)
17921
- - pattern: |
17922
- $SB.WriteString(...)
17923
- - metavariable-regex:
17924
- metavariable: $SQLSTR
17925
- regex: (?i)(select|delete|insert|create|update|alter|drop).*
17926
- - patterns:
17927
- - pattern-either:
17928
- - pattern: fmt.Fprintf($F, "$SQLSTR", ...)
17929
- - pattern: fmt.Sprintf("$SQLSTR", ...)
17930
- - pattern: fmt.Printf("$SQLSTR", ...)
17931
- - metavariable-regex:
17932
- metavariable: $SQLSTR
17933
- regex: \s*(?i)(select|delete|insert|create|update|alter|drop)\b.*%(v|s|q).*
17934
- pattern-sanitizers:
17935
- - pattern-either:
17936
- - pattern: strconv.Atoi(...)
17937
- - pattern: |
17938
- ($X: bool)
17939
- - id: java.lang.security.audit.md5-used-as-password.md5-used-as-password
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
17940
18005
  languages:
17941
- - java
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.
18012
+ languages:
18013
+ - kt
17942
18014
  severity: WARNING
17943
- message: It looks like MD5 is used as a password hash. MD5 is not considered a secure
17944
- password hash because it can be cracked by an attacker in a short amount of time.
17945
- Use a suitable password hashing function such as PBKDF2 or bcrypt. You can use
17946
- `javax.crypto.SecretKeyFactory` with `SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1")`
17947
- or, if using Spring, `org.springframework.security.crypto.bcrypt`.
17948
18015
  metadata:
17949
- category: security
17950
- technology:
17951
- - java
17952
- - md5
17953
- references:
17954
- - https://tools.ietf.org/id/draft-lvelvindron-tls-md5-sha1-deprecate-01.html
17955
- - https://github.com/returntocorp/semgrep-rules/issues/1609
17956
- - https://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#SecretKeyFactory
17957
- - https://docs.spring.io/spring-security/site/docs/current/api/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoder.html
17958
18016
  owasp:
17959
18017
  - A03:2017 - Sensitive Data Exposure
17960
18018
  - A02:2021 - Cryptographic Failures
17961
18019
  - A04:2025 - Cryptographic Failures
17962
18020
  cwe:
17963
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
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
17964
18028
  subcategory:
17965
18029
  - vuln
17966
- likelihood: HIGH
18030
+ likelihood: LOW
17967
18031
  impact: MEDIUM
17968
18032
  confidence: MEDIUM
17969
18033
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
17970
18034
  vulnerability_class:
17971
- - Cryptographic Issues
17972
- source: https://semgrep.dev/r/java.lang.security.audit.md5-used-as-password.md5-used-as-password
17973
- shortlink: https://sg.run/JxEQ
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
17974
18038
  semgrep.dev:
17975
18039
  rule:
17976
- r_id: 14690
17977
- rv_id: 1263029
17978
- rule_id: JDULAW
17979
- version_id: bZT53QB
17980
- url: https://semgrep.dev/playground/r/bZT53QB/java.lang.security.audit.md5-used-as-password.md5-used-as-password
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
17981
18045
  origin: community
17982
- mode: taint
17983
- pattern-sources:
17984
- - patterns:
17985
- - pattern-inside: |
17986
- $TYPE $MD = MessageDigest.getInstance("MD5");
17987
- ...
17988
- - pattern: $MD.digest(...);
17989
- pattern-sinks:
17990
- - patterns:
17991
- - pattern: $MODEL.$METHOD(...);
17992
- - metavariable-regex:
17993
- metavariable: $METHOD
17994
- regex: (?i)(.*password.*)
17995
- - id: javascript.express.security.injection.raw-html-format.raw-html-format
17996
- message: User data flows into the host portion of this manually-constructed HTML.
17997
- This can introduce a Cross-Site-Scripting (XSS) vulnerability if this comes from
17998
- user-provided input. Consider using a sanitization library such as DOMPurify to
17999
- sanitize the HTML within.
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.
18000
18058
  metadata:
18001
18059
  cwe:
18002
- - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
18003
- Scripting'')'
18060
+ - 'CWE-704: Incorrect Type Conversion or Cast'
18004
18061
  owasp:
18005
- - A07:2017 - Cross-Site Scripting (XSS)
18062
+ - A01:2017 - Injection
18006
18063
  - A03:2021 - Injection
18007
18064
  - A05:2025 - Injection
18008
18065
  references:
18009
- - https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
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
18010
18069
  category: security
18011
18070
  technology:
18012
- - express
18013
- cwe2022-top25: true
18014
- cwe2021-top25: true
18071
+ - sqlalchemy
18072
+ - flask
18015
18073
  subcategory:
18016
18074
  - vuln
18017
- likelihood: HIGH
18018
18075
  impact: MEDIUM
18076
+ likelihood: MEDIUM
18019
18077
  confidence: MEDIUM
18020
18078
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18021
18079
  vulnerability_class:
18022
- - Cross-Site-Scripting (XSS)
18023
- source: https://semgrep.dev/r/javascript.express.security.injection.raw-html-format.raw-html-format
18024
- shortlink: https://sg.run/5DO3
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
18025
18083
  semgrep.dev:
18026
18084
  rule:
18027
- r_id: 14691
18028
- rv_id: 1263175
18029
- rule_id: 5rUL0X
18030
- version_id: NdTzyQv
18031
- url: https://semgrep.dev/playground/r/NdTzyQv/javascript.express.security.injection.raw-html-format.raw-html-format
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
18032
18090
  origin: community
18091
+ severity: ERROR
18033
18092
  languages:
18034
- - javascript
18035
- - typescript
18036
- severity: WARNING
18093
+ - python
18037
18094
  mode: taint
18038
18095
  pattern-sources:
18039
- - label: EXPRESS
18040
- patterns:
18096
+ - patterns:
18041
18097
  - pattern-either:
18042
- - pattern-inside: function ... ($REQ, $RES) {...}
18043
- - pattern-inside: function ... ($REQ, $RES, $NEXT) {...}
18098
+ - pattern: flask.request.$ANYTHING
18044
18099
  - patterns:
18045
- - pattern-either:
18046
- - pattern-inside: $APP.$METHOD(..., function $FUNC($REQ, $RES) {...})
18047
- - pattern-inside: $APP.$METHOD(..., function $FUNC($REQ, $RES, $NEXT) {...})
18048
- - metavariable-regex:
18049
- metavariable: $METHOD
18050
- regex: ^(get|post|put|head|delete|options)$
18051
- - pattern-either:
18052
- - pattern: $REQ.query
18053
- - pattern: $REQ.body
18054
- - pattern: $REQ.params
18055
- - pattern: $REQ.cookies
18056
- - pattern: $REQ.headers
18057
- - label: EXPRESSTS
18058
- patterns:
18059
- - pattern-either:
18060
- - pattern-inside: |
18061
- ({ $REQ }: Request,$RES: Response, $NEXT: NextFunction) =>
18062
- {...}
18063
- - pattern-inside: |
18064
- ({ $REQ }: Request,$RES: Response) => {...}
18065
- - focus-metavariable: $REQ
18066
- - pattern-either:
18067
- - pattern: params
18068
- - pattern: query
18069
- - pattern: cookies
18070
- - pattern: headers
18071
- - pattern: body
18072
- - label: CLEAN
18073
- by-side-effect: true
18074
- patterns:
18075
- - pattern-either:
18076
- - pattern: $A($SOURCE)
18077
- - pattern: $SANITIZE. ... .$A($SOURCE)
18078
- - pattern: $A. ... .$SANITIZE($SOURCE)
18079
- - focus-metavariable: $SOURCE
18080
- - metavariable-regex:
18081
- metavariable: $A
18082
- regex: (?i)(.*valid|.*sanitiz)
18100
+ - pattern-inside: |
18101
+ @$APP.route(...)
18102
+ def $FUNC(..., $ROUTEVAR, ...):
18103
+ ...
18104
+ - pattern: $ROUTEVAR
18083
18105
  pattern-sinks:
18084
- - requires: (EXPRESS and not CLEAN) or (EXPRESSTS and not CLEAN)
18085
- patterns:
18086
- - pattern-either:
18087
- - patterns:
18088
- - pattern-either:
18089
- - pattern: '"$HTMLSTR" + $EXPR'
18090
- - pattern: '"$HTMLSTR".concat(...)'
18091
- - pattern: util.format($HTMLSTR, ...)
18092
- - metavariable-pattern:
18093
- metavariable: $HTMLSTR
18094
- language: generic
18095
- pattern: <$TAG ...
18096
- - patterns:
18097
- - pattern: |
18098
- `...`
18099
- - pattern-regex: |
18100
- .*<\w+.*
18101
- - id: kotlin.lang.security.ecb-cipher.ecb-cipher
18102
- metadata:
18103
- cwe:
18104
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
18105
- owasp:
18106
- - A03:2017 - Sensitive Data Exposure
18107
- - A02:2021 - Cryptographic Failures
18108
- - A04:2025 - Cryptographic Failures
18109
- source-rule-url: https://find-sec-bugs.github.io/bugs.htm#ECB_MODE
18110
- category: security
18111
- technology:
18112
- - kotlin
18113
- references:
18114
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
18115
- subcategory:
18116
- - vuln
18117
- likelihood: LOW
18118
- impact: MEDIUM
18119
- confidence: MEDIUM
18120
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18121
- vulnerability_class:
18122
- - Cryptographic Issues
18123
- source: https://semgrep.dev/r/kotlin.lang.security.ecb-cipher.ecb-cipher
18124
- shortlink: https://sg.run/DzLj
18125
- semgrep.dev:
18126
- rule:
18127
- r_id: 14696
18128
- rv_id: 1263263
18129
- rule_id: DbU1Zd
18130
- version_id: YDTZexg
18131
- url: https://semgrep.dev/playground/r/YDTZexg/kotlin.lang.security.ecb-cipher.ecb-cipher
18132
- origin: community
18133
- message: Cipher in ECB mode is detected. ECB mode produces the same output for the
18134
- same input each time which allows an attacker to intercept and replay the data.
18135
- Further, ECB mode does not provide any integrity checking. See https://find-sec-bugs.github.io/bugs.htm#CIPHER_INTEGRITY.
18136
- severity: WARNING
18137
- languages:
18138
- - kt
18139
- patterns:
18140
- - pattern-either:
18141
- - pattern: |
18142
- val $VAR : Cipher = $CIPHER.getInstance($MODE)
18143
- - pattern: |
18144
- var $VAR : Cipher = $CIPHER.getInstance($MODE)
18145
- - pattern: |
18146
- val $VAR = $CIPHER.getInstance($MODE)
18147
- - pattern: |
18148
- var $VAR = $CIPHER.getInstance($MODE)
18149
- - metavariable-regex:
18150
- metavariable: $MODE
18151
- regex: .*ECB.*
18152
- - id: kotlin.lang.security.no-null-cipher.no-null-cipher
18153
- pattern: NullCipher(...)
18154
- metadata:
18155
- cwe:
18156
- - 'CWE-327: Use of a Broken or Risky Cryptographic Algorithm'
18157
- owasp:
18158
- - A03:2017 - Sensitive Data Exposure
18159
- - A02:2021 - Cryptographic Failures
18160
- - A04:2025 - Cryptographic Failures
18161
- source-rule-url: https://find-sec-bugs.github.io/bugs.htm#NULL_CIPHER
18162
- asvs:
18163
- section: V6 Stored Cryptography Verification Requirements
18164
- control_id: 6.2.5 Insecure Algorithm
18165
- control_url: https://github.com/OWASP/ASVS/blob/master/4.0/en/0x14-V6-Cryptography.md#v62-algorithms
18166
- version: '4'
18167
- category: security
18168
- technology:
18169
- - kotlin
18170
- references:
18171
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
18172
- subcategory:
18173
- - vuln
18174
- likelihood: LOW
18175
- impact: MEDIUM
18176
- confidence: MEDIUM
18177
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18178
- vulnerability_class:
18179
- - Cryptographic Issues
18180
- source: https://semgrep.dev/r/kotlin.lang.security.no-null-cipher.no-null-cipher
18181
- shortlink: https://sg.run/0ywb
18182
- semgrep.dev:
18183
- rule:
18184
- r_id: 14698
18185
- rv_id: 1263265
18186
- rule_id: 0oU2Yy
18187
- version_id: o5TbDPj
18188
- url: https://semgrep.dev/playground/r/o5TbDPj/kotlin.lang.security.no-null-cipher.no-null-cipher
18189
- origin: community
18190
- message: 'NullCipher was detected. This will not encrypt anything; the cipher text
18191
- will be the same as the plain text. Use a valid, secure cipher: Cipher.getInstance("AES/CBC/PKCS7PADDING").
18192
- See https://owasp.org/www-community/Using_the_Java_Cryptographic_Extensions for
18193
- more information.'
18194
- severity: WARNING
18195
- languages:
18196
- - kt
18197
- - scala
18198
- - id: kotlin.lang.security.use-of-md5.use-of-md5
18199
- message: Detected MD5 hash algorithm which is considered insecure. MD5 is not collision
18200
- resistant and is therefore not suitable as a cryptographic signature. Use SHA256
18201
- or SHA3 instead.
18202
- languages:
18203
- - kt
18204
- severity: WARNING
18205
- metadata:
18206
- owasp:
18207
- - A03:2017 - Sensitive Data Exposure
18208
- - A02:2021 - Cryptographic Failures
18209
- - A04:2025 - Cryptographic Failures
18210
- cwe:
18211
- - 'CWE-328: Use of Weak Hash'
18212
- source-rule-url: https://find-sec-bugs.github.io/bugs.htm#WEAK_MESSAGE_DIGEST_MD5
18213
- category: security
18214
- technology:
18215
- - kotlin
18216
- references:
18217
- - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
18218
- subcategory:
18219
- - vuln
18220
- likelihood: LOW
18221
- impact: MEDIUM
18222
- confidence: MEDIUM
18223
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18224
- vulnerability_class:
18225
- - Insecure Hashing Algorithm
18226
- source: https://semgrep.dev/r/kotlin.lang.security.use-of-md5.use-of-md5
18227
- shortlink: https://sg.run/4eQx
18228
- semgrep.dev:
18229
- rule:
18230
- r_id: 14700
18231
- rv_id: 1263267
18232
- rule_id: qNUXPj
18233
- version_id: pZT03Jd
18234
- url: https://semgrep.dev/playground/r/pZT03Jd/kotlin.lang.security.use-of-md5.use-of-md5
18235
- origin: community
18236
- pattern-either:
18237
- - pattern: |
18238
- java.security.MessageDigest.getInstance("MD5")
18239
- - pattern: |
18240
- org.apache.commons.codec.digest.DigestUtils.getMd5Digest()
18241
- - id: python.flask.security.injection.tainted-sql-string.tainted-sql-string
18242
- message: Detected user input used to manually construct a SQL string. This is usually
18243
- bad practice because manual construction could accidentally result in a SQL injection.
18244
- An attacker could use a SQL injection to steal or modify contents of the database.
18245
- Instead, use a parameterized query which is available by default in most database
18246
- engines. Alternatively, consider using an object-relational mapper (ORM) such
18247
- as SQLAlchemy which will protect your queries.
18248
- metadata:
18249
- cwe:
18250
- - 'CWE-704: Incorrect Type Conversion or Cast'
18251
- owasp:
18252
- - A01:2017 - Injection
18253
- - A03:2021 - Injection
18254
- - A05:2025 - Injection
18255
- references:
18256
- - https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-textual-sql
18257
- - https://www.tutorialspoint.com/sqlalchemy/sqlalchemy_quick_guide.htm
18258
- - https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-more-specific-text-with-table-expression-literal-column-and-expression-column
18259
- category: security
18260
- technology:
18261
- - sqlalchemy
18262
- - flask
18263
- subcategory:
18264
- - vuln
18265
- impact: MEDIUM
18266
- likelihood: MEDIUM
18267
- confidence: MEDIUM
18268
- license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
18269
- vulnerability_class:
18270
- - Improper Validation
18271
- source: https://semgrep.dev/r/python.flask.security.injection.tainted-sql-string.tainted-sql-string
18272
- shortlink: https://sg.run/JxZj
18273
- semgrep.dev:
18274
- rule:
18275
- r_id: 14702
18276
- rv_id: 1409402
18277
- rule_id: YGUDKQ
18278
- version_id: A8TEvb4
18279
- url: https://semgrep.dev/playground/r/A8TEvb4/python.flask.security.injection.tainted-sql-string.tainted-sql-string
18280
- origin: community
18281
- severity: ERROR
18282
- languages:
18283
- - python
18284
- mode: taint
18285
- pattern-sources:
18286
- - patterns:
18287
- - pattern-either:
18288
- - pattern: flask.request.$ANYTHING
18289
- - patterns:
18290
- - pattern-inside: |
18291
- @$APP.route(...)
18292
- def $FUNC(..., $ROUTEVAR, ...):
18293
- ...
18294
- - pattern: $ROUTEVAR
18295
- pattern-sinks:
18296
- - patterns:
18106
+ - patterns:
18297
18107
  - pattern-either:
18298
18108
  - pattern: |
18299
18109
  "$SQLSTR" + ...
@@ -41342,78 +41152,268 @@ rules:
41342
41152
  - pattern-regex: \$\{\{\s*secrets\.
41343
41153
  - pattern-not-inside: 'jobs: ...'
41344
41154
  severity: WARNING
41345
- - id: python.lang.security.audit.insecure-file-permissions.insecure-file-permissions
41155
+ - id: ruby.rails.security.injection.raw-html-format.raw-html-format
41346
41156
  languages:
41347
- - python
41157
+ - ruby
41348
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`.
41349
41165
  metadata:
41166
+ cwe:
41167
+ - 'CWE-79: Improper Neutralization of Input During Web Page Generation (''Cross-site
41168
+ Scripting'')'
41169
+ owasp:
41170
+ - A07:2017 - Cross-Site Scripting (XSS)
41171
+ - A03:2021 - Injection
41172
+ - A05:2025 - Injection
41350
41173
  category: security
41174
+ technology:
41175
+ - 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
+ cwe2022-top25: true
41180
+ cwe2021-top25: true
41181
+ subcategory:
41182
+ - vuln
41183
+ likelihood: HIGH
41184
+ impact: MEDIUM
41185
+ confidence: MEDIUM
41186
+ license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
41187
+ 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
41191
+ semgrep.dev:
41192
+ 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
41198
+ 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
41229
+ 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:
41351
41237
  owasp:
41352
- - A01:2021 - Broken Access Control
41353
- - A01:2025 - Broken Access Control
41238
+ - A03:2021 - Injection
41239
+ - A05:2025 - Injection
41354
41240
  cwe:
41355
- - 'CWE-276: Incorrect Default Permissions'
41241
+ - 'CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code
41242
+ (''Eval Injection'')'
41243
+ category: security
41356
41244
  technology:
41357
- - python
41245
+ - bash
41246
+ - curl
41247
+ confidence: MEDIUM
41358
41248
  references:
41359
- - https://owasp.org/Top10/A01_2021-Broken_Access_Control
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
41267
+ mode: taint
41268
+ pattern-sources:
41269
+ - pattern: |
41270
+ $(curl ...)
41271
+ - pattern: |
41272
+ `curl ...`
41273
+ pattern-sinks:
41274
+ - pattern: eval ...
41275
+ - id: python.flask.security.injection.tainted-url-host.tainted-url-host
41276
+ languages:
41277
+ - 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.
41285
+ metadata:
41286
+ cwe:
41287
+ - 'CWE-918: Server-Side Request Forgery (SSRF)'
41288
+ owasp:
41289
+ - A10:2021 - Server-Side Request Forgery (SSRF)
41290
+ - A01:2025 - Broken Access Control
41291
+ references:
41292
+ - https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
41293
+ category: security
41294
+ technology:
41295
+ - flask
41360
41296
  cwe2022-top25: true
41361
41297
  cwe2021-top25: true
41362
41298
  subcategory:
41363
41299
  - vuln
41364
- likelihood: LOW
41365
41300
  impact: MEDIUM
41301
+ likelihood: MEDIUM
41366
41302
  confidence: MEDIUM
41367
41303
  license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
41368
41304
  vulnerability_class:
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
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
41372
41308
  semgrep.dev:
41373
41309
  rule:
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
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
41379
41315
  origin: community
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
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
+ confidence: MEDIUM
41390
+ subcategory:
41391
+ - vuln
41392
+ likelihood: MEDIUM
41393
+ impact: MEDIUM
41394
+ interfile: true
41395
+ license: Semgrep Rules License v1.0. For more details, visit semgrep.dev/legal/rules-license
41396
+ 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
41400
+ semgrep.dev:
41401
+ 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
41407
+ 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.*)