Repository navigation
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.
…lp and test Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
| predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) { | ||
| exists(ComparisonTest ct | | ||
| ct.getExpr() = succ.asExpr() and | ||
| ct.getAnArgument() = pred.asExpr() |
There was a problem hiding this comment.
Fixed in 8624c4b. Both parameter-based Equals forms produce the expected alerts with the existing comparison step; the targeted test passes.
|
@copilot Please address the open review finding:
Leave the code quality note on |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Fixed in 8624c4b. Both cases are reported; the targeted test, strict compile, formatting and default-suite checks pass. The obsolete-API fixture is unchanged. The prior-head Build CodeQL Packs run remains in progress in C# tests, so its overall result is not yet available. |

The new C# query reports a condition on a reverse DNS host name that guards a sensitive action (CWE-350, CWE-807, CWE-247). An attacker who controls the PTR record of their own address controls that host name. The standard
cs/user-controlled-bypassmisses most of these cases for two reasons:Dns.GetHostByAddressas a reverse lookup.==andEqualsonly when the other operand is a constant.Query (
csharp/src/security/CWE-350/)ConditionalBypassQuery, so a "sensitive action" means the same as incs/user-controlled-bypass: login and authorization methods, and socketSend.Dns.GetHostByAddressDns.GetHostEntryandDns.GetHostEntryAsyncwhen parameter 0 isSystem.Net.IPAddressComparisonTestto its result. It applies to this query only.@precision high,@security-severity 7.5, taggedexperimental. With precisionhigh,csharp.qlsselects the query, so default-suite users get it from the release that ships it..qhelpwith inline samples.Test (
csharp/test/security/CWE-350/ReverseDnsConditionalBypass/)GetHostEntry,GetHostEntryAsyncandGetHostByAddress; theEquals,==andEndsWithcomparisons; and comparisons with a constant, a parameter and a local variable.IPAddress.EqualsLogincall on both branchesConsole.WriteLine.cs/user-controlled-bypassreports only theGetHostByAddresscase.Changes from the draft
cs/reverse-dns-user-controlled-bypassbecomesgithubsecuritylab/cs/reverse-dns-user-controlled-bypass. The.mdhelp became.qhelp..qlrefusesTestUtilities/PrettyPrintModels.qlwith a.expectedfile instead ofutils/test/InlineExpectationsTestQuery.ql. The upstream postprocess does not compile in this repository: the cachedcodeql/csharp-allpack has no lock file, socodeql/controlflowdoes not resolve.$ Alertmarkers are nowBAD/GOODcomments. I checked them once, before the conversion, with a temporary inline postprocess (not committed), and they all matched.MaD:1892becomesMaD:1, with amodelssection from the postprocess.options: unchanged. The framework assembly references resolve, so the shared stubs are not needed.Known limitations
GetHostEntry(string)called with an address literal is not modelled, and neither isBeginGetHostEntry/EndGetHostEntry.GetHostByAddressflows are also reported bycs/user-controlled-bypass.Follow-ups for the maintainer
githubsecuritylab/codeql-csharp-queriesversion at release time.csharp/test/TestUtilities/so C# tests can use$ Alertmarkers.