From 53a1f935b7b4066b467a81d5e60fcec3962b2787 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Thu, 16 Dec 2021 17:12:50 +0000 Subject: [PATCH] C++: Fix join-order in 'HttpStringLiteral' charpred. --- cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql b/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql index 0ae7e12f90e2..eea551710e50 100644 --- a/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql +++ b/cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql @@ -28,6 +28,11 @@ class PrivateHostName extends string { } } +pragma[nomagic] +predicate privateHostNameFlowsToExpr(Expr e) { + TaintTracking::localExprTaint(any(StringLiteral p | p.getValue() instanceof PrivateHostName), e) +} + /** * A string containing an HTTP URL not in a private domain. */ @@ -38,11 +43,9 @@ class HttpStringLiteral extends StringLiteral { or exists(string tail | tail = s.regexpCapture("http://(.*)", 1) and not tail instanceof PrivateHostName - ) and - not TaintTracking::localExprTaint(any(StringLiteral p | - p.getValue() instanceof PrivateHostName - ), this.getParent*()) - ) + ) + ) and + not privateHostNameFlowsToExpr(this.getParent*()) } }