Module: PWN::SAST::DeserialJava

Defined in:
lib/pwn/sast/deserial_java.rb

Overview

SAST Module used to identify if source may result in exposing the Java application to deserialization vulnerabilities. For more information see: cheatsheetseries.owasp.org/cheatsheets/Deserialization_Cheat_Sheet.html

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. <[email protected]>



65
66
67
68
69
# File 'lib/pwn/sast/deserial_java.rb', line 65

public_class_method def self.authors
  "AUTHOR(S):
    0day Inc. <[email protected]>
  "
end

.helpObject

Display Usage for this Module



73
74
75
76
77
78
79
80
81
82
# File 'lib/pwn/sast/deserial_java.rb', line 73

public_class_method def self.help
  puts "USAGE:
    sast_arr = #{self}.scan(
      :dir_path => 'optional path to dir defaults to .',
      :git_repo_root_uri => 'optional http uri of git repo scanned'
    )

    #{self}.authors
  "
end

.scan(opts = {}) ⇒ Object

Supported Method Parameters

PWN::SAST::DeserialJava.scan(

:dir_path => 'optional path to dir defaults to .'
:git_repo_root_uri => 'optional http uri of git repo scanned'

)



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pwn/sast/deserial_java.rb', line 19

public_class_method def self.scan(opts = {})
  dir_path = opts[:dir_path]
  git_repo_root_uri = opts[:git_repo_root_uri].to_s.scrub

  test_case_filter = "
    grep -in \
    -e readObject \
    -e XMLdecoder \
    -e fromXML \
    -e readObjectNodData \
    -e readResolve \
    -e readExternal \
    -e readUnshared \
    -e Serializable {PWN_SAST_SRC_TARGET} 2> /dev/null
  "

  include_extensions = %w[.java .class .jar .war .ear .nar .properties .aj .jsp .jspx .jstm .jsptml .jnlp .jad .ser .gsp]

  PWN::SAST::TestCaseEngine.execute(
    test_case_filter: test_case_filter,
    security_references: security_references,
    dir_path: dir_path,
    include_extensions: include_extensions,
    git_repo_root_uri: git_repo_root_uri
  )
end

.security_referencesObject

Used primarily to map NIST 800-53 Revision 4 Security Controls web.nvd.nist.gov/view/800-53/Rev4/impact?impactName=HIGH to PWN Exploit & Static Code Anti-Pattern Matching Modules to Determine the level of Testing Coverage w/ PWN.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pwn/sast/deserial_java.rb', line 51

public_class_method def self.security_references
  {
    sast_module: self,
    section: 'INFORMATION INPUT VALIDATION',
    nist_800_53_uri: 'https://csrc.nist.gov/projects/cprt/catalog#/cprt/framework/version/SP_800_53_5_1_1/home?element=SI-10',
    cwe_id: '502',
    cwe_uri: 'https://cwe.mitre.org/data/definitions/502.html'
  }
rescue StandardError => e
  raise e
end