Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d7cbc4

Browse files
committed
Fix comments.
This induced fixing the code, since things were wired up wrongly. Currently the only implementation of `insecure_connection_creation` is `ssl.wrap_socket`, which is also the sole target of py/insecure-default-protocol`, so perhaps this part should be turned off?
1 parent 2e948da commit 7d7cbc4

2 files changed

Lines changed: 40 additions & 17 deletions

File tree

python/ql/src/Security/CWE-327/FluentApiModel.qll

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,49 @@ class InsecureContextConfiguration extends DataFlow::Configuration {
4343
}
4444

4545
/**
46-
* A connection is created from a context allowing an insecure protocol,
47-
* and that protocol has not been restricted appropriately.
46+
* Holds if `conectionCreation` marks the creation of a connetion based on the contex
47+
* found at `contextOrigin` and allowing `insecure_version`.
48+
* `specific` is true iff the context if configured for a specific protocol version rather
49+
* than for a family of protocols.
4850
*/
49-
predicate unsafe_connection_creation(
50-
DataFlow::Node creation, ProtocolVersion insecure_version, DataFlow::Node source, boolean specific
51+
predicate unsafe_connection_creation_with_context(
52+
DataFlow::Node connectionCreation, ProtocolVersion insecure_version, DataFlow::Node contextOrigin,
53+
boolean specific
5154
) {
5255
// Connection created from a context allowing `insecure_version`.
53-
exists(InsecureContextConfiguration c, ProtocolUnrestriction cc | c.hasFlow(cc, creation) |
56+
exists(InsecureContextConfiguration c, ProtocolUnrestriction co |
57+
c.hasFlow(co, connectionCreation)
58+
|
5459
insecure_version = c.getTrackedVersion() and
55-
source = cc and
60+
contextOrigin = co and
5661
specific = false
5762
)
5863
or
5964
// Connection created from a context specifying `insecure_version`.
6065
exists(TlsLibrary l, DataFlow::CfgNode cc |
6166
cc = l.insecure_connection_creation(insecure_version)
6267
|
63-
creation = cc and
64-
source = cc and
68+
connectionCreation = cc and
69+
contextOrigin = cc and
6570
specific = true
6671
)
6772
}
6873

69-
/** A connection is created insecurely without reference to a context. */
70-
predicate unsafe_context_creation(DataFlow::CallCfgNode call, string insecure_version) {
74+
/**
75+
* Holds if `conectionCreation` marks the creation of a connetion witout reference to a context
76+
* and allowing `insecure_version`.
77+
* `specific` is true iff the context if configured for a specific protocol version rather
78+
* than for a family of protocols.
79+
*/
80+
predicate unsafe_connection_creation_without_context(
81+
DataFlow::CallCfgNode connectionCreation, string insecure_version
82+
) {
83+
exists(TlsLibrary l | connectionCreation = l.insecure_connection_creation(insecure_version))
84+
}
85+
86+
/** Holds if `contextCreation` is creating a context ties to a specific insecure version. */
87+
predicate unsafe_context_creation(DataFlow::CallCfgNode contextCreation, string insecure_version) {
7188
exists(TlsLibrary l, ContextCreation cc | cc = l.insecure_context_creation(insecure_version) |
72-
cc = call
89+
contextCreation = cc
7390
)
7491
}

python/ql/src/Security/CWE-327/InsecureProtocol.ql

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ string verb(boolean specific) {
3333
}
3434

3535
from
36-
DataFlow::Node creation, string insecure_version, DataFlow::Node contextOrigin, boolean specific
36+
DataFlow::Node connectionCreation, string insecure_version, DataFlow::Node protocolConfiguration,
37+
boolean specific
3738
where
38-
unsafe_connection_creation(creation, insecure_version, contextOrigin, specific)
39+
unsafe_connection_creation_with_context(connectionCreation, insecure_version,
40+
protocolConfiguration, specific)
3941
or
40-
unsafe_context_creation(creation, insecure_version) and
41-
contextOrigin = creation and
42+
unsafe_connection_creation_without_context(connectionCreation, insecure_version) and
43+
protocolConfiguration = connectionCreation and
4244
specific = true
43-
select creation,
45+
or
46+
unsafe_context_creation(protocolConfiguration, insecure_version) and
47+
connectionCreation = protocolConfiguration and
48+
specific = true
49+
select connectionCreation,
4450
"Insecure SSL/TLS protocol version " + insecure_version + " " + verb(specific) + " by $@ ",
45-
contextOrigin, originName(contextOrigin)
51+
protocolConfiguration, originName(protocolConfiguration)

0 commit comments

Comments
 (0)