Repository navigation
Conversation
Contributor
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.