|
| 1 | +/** |
| 2 | + * @name Query Sinks |
| 3 | + * @description List all query sinks found in the database. Query sinks are |
| 4 | + * potential results depending on what data flows to them and |
| 5 | + * other context. |
| 6 | + * @kind problem |
| 7 | + * @problem.severity info |
| 8 | + * @id swift/summary/query-sinks |
| 9 | + * @tags summary |
| 10 | + */ |
| 11 | + |
| 12 | +/* |
| 13 | + * Most queries compute data flow to one of the following sinks: |
| 14 | + * - custom per-query sinks (listed by this query, `swift/summary/query-sinks`). |
| 15 | + * - regular expression evaluation (see `swift/summary/regex-evals`). |
| 16 | + */ |
| 17 | + |
| 18 | +import swift |
| 19 | +import codeql.swift.dataflow.DataFlow |
| 20 | +import codeql.swift.security.PathInjectionQuery |
| 21 | +import codeql.swift.security.UnsafeWebViewFetchQuery |
| 22 | +import codeql.swift.security.SqlInjectionQuery |
| 23 | +import codeql.swift.security.UnsafeJsEvalQuery |
| 24 | +import codeql.swift.security.UncontrolledFormatStringQuery |
| 25 | +import codeql.swift.security.StringLengthConflationQuery |
| 26 | +import codeql.swift.security.ConstantPasswordQuery |
| 27 | +import codeql.swift.security.CleartextStorageDatabaseQuery |
| 28 | +import codeql.swift.security.CleartextTransmissionQuery |
| 29 | +import codeql.swift.security.CleartextLoggingQuery |
| 30 | +import codeql.swift.security.CleartextStoragePreferencesQuery |
| 31 | +import codeql.swift.security.HardcodedEncryptionKeyQuery |
| 32 | +import codeql.swift.security.ECBEncryptionQuery |
| 33 | +import codeql.swift.security.WeakSensitiveDataHashingQuery |
| 34 | +import codeql.swift.security.XXEQuery |
| 35 | +import codeql.swift.security.InsecureTLSQuery |
| 36 | +import codeql.swift.security.ConstantSaltQuery |
| 37 | +import codeql.swift.security.InsufficientHashIterationsQuery |
| 38 | +import codeql.swift.security.PredicateInjectionQuery |
| 39 | +import codeql.swift.security.StaticInitializationVectorQuery |
| 40 | + |
| 41 | +string queryForSink(DataFlow::Node sink) { |
| 42 | + PathInjectionConfig::isSink(sink) and result = "swift/path-injection" |
| 43 | + or |
| 44 | + UnsafeWebViewFetchConfig::isSink(sink) and result = "swift/unsafe-webview-fetch" |
| 45 | + or |
| 46 | + SqlInjectionConfig::isSink(sink) and result = "swift/sql-injection" |
| 47 | + or |
| 48 | + UnsafeJsEvalConfig::isSink(sink) and result = "swift/unsafe-js-eval" |
| 49 | + or |
| 50 | + TaintedFormatConfig::isSink(sink) and result = "swift/uncontrolled-format-string" |
| 51 | + or |
| 52 | + StringLengthConflationConfig::isSink(sink) and result = "swift/string-length-conflation" |
| 53 | + or |
| 54 | + ConstantPasswordConfig::isSink(sink) and result = "swift/constant-password" |
| 55 | + or |
| 56 | + CleartextStorageDatabaseConfig::isSink(sink) and result = "swift/cleartext-storage-database" |
| 57 | + or |
| 58 | + CleartextTransmissionConfig::isSink(sink) and result = "swift/cleartext-transmission" |
| 59 | + or |
| 60 | + CleartextLoggingConfig::isSink(sink) and result = "swift/cleartext-logging" |
| 61 | + or |
| 62 | + CleartextStoragePreferencesConfig::isSink(sink) and result = "swift/cleartext-storage-preferences" |
| 63 | + or |
| 64 | + HardcodedKeyConfig::isSink(sink) and result = "swift/hardcoded-key" |
| 65 | + or |
| 66 | + EcbEncryptionConfig::isSink(sink) and result = "swift/ecb-encryption" |
| 67 | + or |
| 68 | + WeakHashingConfig::isSink(sink) and result = "swift/weak-sensitive-data-hashing" |
| 69 | + or |
| 70 | + XxeConfig::isSink(sink) and result = "swift/xxe" |
| 71 | + or |
| 72 | + InsecureTlsConfig::isSink(sink) and result = "swift/insecure-tls" |
| 73 | + or |
| 74 | + ConstantSaltConfig::isSink(sink) and result = "swift/constant-salt" |
| 75 | + or |
| 76 | + InsufficientHashIterationsConfig::isSink(sink) and result = "swift/insufficient-hash-iterations" |
| 77 | + or |
| 78 | + PredicateInjectionConfig::isSink(sink) and result = "swift/predicate-injection" |
| 79 | + or |
| 80 | + StaticInitializationVectorConfig::isSink(sink) and result = "swift/static-initialization-vector" |
| 81 | +} |
| 82 | + |
| 83 | +from DataFlow::Node n |
| 84 | +select n, "Sink for " + queryForSink(n) |
0 commit comments