|
| 1 | +id: scrypt-hardcoded-secret-swift |
| 2 | +language: swift |
| 3 | +severity: warning |
| 4 | +message: >- |
| 5 | + A secret is hard-coded in the application. Secrets stored in source |
| 6 | + code, such as credentials, identifiers, and other types of sensitive data, |
| 7 | + can be leaked and used by internal or external malicious actors. Use |
| 8 | + environment variables to securely provide credentials and other secrets or |
| 9 | + retrieve them from a secure vault or Hardware Security Module (HSM). |
| 10 | +note: >- |
| 11 | + [OWASP A07:2021]:Identification and Authentication Failures |
| 12 | + [CWE-798]: Use of Hard-coded Credentials |
| 13 | + [REFERENCES] |
| 14 | + https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html |
| 15 | +utils: |
| 16 | + match_property_declaration: |
| 17 | + kind: property_declaration |
| 18 | + all: |
| 19 | + - has: |
| 20 | + stopBy: end |
| 21 | + kind: call_expression |
| 22 | + has: |
| 23 | + stopBy: end |
| 24 | + kind: value_argument |
| 25 | + all: |
| 26 | + - has: |
| 27 | + stopBy: end |
| 28 | + kind: simple_identifier |
| 29 | + field: name |
| 30 | + regex: "^password$" |
| 31 | + - has: |
| 32 | + stopBy: end |
| 33 | + kind: simple_identifier |
| 34 | + field: value |
| 35 | + pattern: $R |
| 36 | + - follows: |
| 37 | + stopBy: end |
| 38 | + kind: property_declaration |
| 39 | + has: |
| 40 | + stopBy: end |
| 41 | + kind: pattern |
| 42 | + has: |
| 43 | + kind: simple_identifier |
| 44 | + pattern: $R |
| 45 | + match_call_expression: |
| 46 | + kind: call_expression |
| 47 | + has: |
| 48 | + stopBy: end |
| 49 | + kind: navigation_expression |
| 50 | + has: |
| 51 | + stopBy: end |
| 52 | + kind: value_argument |
| 53 | + all: |
| 54 | + - has: |
| 55 | + stopBy: end |
| 56 | + kind: simple_identifier |
| 57 | + regex: "^password$" |
| 58 | + - has: |
| 59 | + stopBy: end |
| 60 | + kind: line_string_literal |
| 61 | + has: |
| 62 | + stopBy: end |
| 63 | + kind: line_str_text |
| 64 | + match_call_expression_follows_property_declaration: |
| 65 | + kind: call_expression |
| 66 | + has: |
| 67 | + stopBy: end |
| 68 | + kind: navigation_expression |
| 69 | + all: |
| 70 | + - has: |
| 71 | + stopBy: end |
| 72 | + kind: call_expression |
| 73 | + has: |
| 74 | + kind: simple_identifier |
| 75 | + regex: "^Scrypt$" |
| 76 | + - has: |
| 77 | + stopBy: end |
| 78 | + kind: call_suffix |
| 79 | + has: |
| 80 | + kind: value_arguments |
| 81 | + all: |
| 82 | + - has: |
| 83 | + kind: value_argument |
| 84 | + all: |
| 85 | + - has: |
| 86 | + kind: simple_identifier |
| 87 | + field: name |
| 88 | + regex: "^password$" |
| 89 | + - has: |
| 90 | + kind: simple_identifier |
| 91 | + field: value |
| 92 | + pattern: $M |
| 93 | + follows: |
| 94 | + stopBy: end |
| 95 | + kind: property_declaration |
| 96 | + all: |
| 97 | + - has: |
| 98 | + stopBy: end |
| 99 | + kind: value_binding_pattern |
| 100 | + regex: "^let$" |
| 101 | + - has: |
| 102 | + stopBy: end |
| 103 | + kind: pattern |
| 104 | + field: name |
| 105 | + has: |
| 106 | + stopBy: end |
| 107 | + kind: simple_identifier |
| 108 | + field: bound_identifier |
| 109 | + pattern: $M |
| 110 | + - has: |
| 111 | + stopBy: end |
| 112 | + kind: type_annotation |
| 113 | + - has: |
| 114 | + stopBy: end |
| 115 | + kind: call_expression |
| 116 | + match_follows_line_string_literal: |
| 117 | + kind: call_expression |
| 118 | + has: |
| 119 | + stopBy: end |
| 120 | + kind: navigation_expression |
| 121 | + all: |
| 122 | + - has: |
| 123 | + stopBy: end |
| 124 | + kind: call_expression |
| 125 | + has: |
| 126 | + stopBy: end |
| 127 | + kind: simple_identifier |
| 128 | + regex: "^Scrypt$" |
| 129 | + - has: |
| 130 | + stopBy: end |
| 131 | + kind: call_suffix |
| 132 | + all: |
| 133 | + - has: |
| 134 | + stopBy: end |
| 135 | + kind: value_arguments |
| 136 | + - has: |
| 137 | + stopBy: end |
| 138 | + kind: value_argument |
| 139 | + has: |
| 140 | + stopBy: end |
| 141 | + kind: simple_identifier |
| 142 | + field: name |
| 143 | + regex: "^password$" |
| 144 | + - has: |
| 145 | + stopBy: end |
| 146 | + kind: call_expression |
| 147 | + has: |
| 148 | + stopBy: end |
| 149 | + kind: simple_identifier |
| 150 | + regex: "^Array$" |
| 151 | + - has: |
| 152 | + stopBy: end |
| 153 | + kind: call_suffix |
| 154 | + - has: |
| 155 | + stopBy: end |
| 156 | + kind: value_arguments |
| 157 | + - has: |
| 158 | + stopBy: end |
| 159 | + kind: value_argument |
| 160 | + - has: |
| 161 | + stopBy: end |
| 162 | + kind: navigation_expression |
| 163 | + has: |
| 164 | + stopBy: end |
| 165 | + kind: simple_identifier |
| 166 | + pattern: $L |
| 167 | + - has: |
| 168 | + stopBy: end |
| 169 | + kind: navigation_suffix |
| 170 | + has: |
| 171 | + stopBy: end |
| 172 | + kind: simple_identifier |
| 173 | + regex: "^utf8$" |
| 174 | + follows: |
| 175 | + kind: property_declaration |
| 176 | + all: |
| 177 | + - has: |
| 178 | + kind: value_binding_pattern |
| 179 | + regex: "^let$" |
| 180 | + - has: |
| 181 | + kind: pattern |
| 182 | + field: name |
| 183 | + has: |
| 184 | + kind: simple_identifier |
| 185 | + field: bound_identifier |
| 186 | + pattern: $L |
| 187 | + - has: |
| 188 | + kind: line_string_literal |
| 189 | + field: value |
| 190 | + has: |
| 191 | + kind: line_str_text |
| 192 | + field: text |
| 193 | + |
| 194 | +rule: |
| 195 | + any: |
| 196 | + - matches: match_property_declaration |
| 197 | + - matches: match_call_expression |
| 198 | + - matches: match_call_expression_follows_property_declaration |
| 199 | + - matches: match_follows_line_string_literal |
0 commit comments