Visitar URL original
UAF not flagged · Issue #15806 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20240324153234/https://github.com/github/codeql/issues/15806
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UAF not flagged #15806

Open
tardigrade-9 opened this issue Mar 5, 2024 · 0 comments
Open

UAF not flagged #15806

tardigrade-9 opened this issue Mar 5, 2024 · 0 comments
Labels
C++ question Further information is requested

Comments

@tardigrade-9
Copy link

tardigrade-9 commented Mar 5, 2024 •

I borrowed the query from UseAfterFree.ql present in CodeQL repo and modified to include a custom free function, but the query is not flagging UAF.

import cpp
import semmle.code.cpp.dataflow.new.DataFlow
import semmle.code.cpp.ir.IR
import semmle.code.cpp.security.flowafterfree.FlowAfterFree
import semmle.code.cpp.security.flowafterfree.UseAfterFree
import UseAfterFreeTrace::PathGraph

module UseAfterFreeParam implements FlowFromFreeParamSig {
  predicate isSink = isUse/2;

  predicate isExcluded = isExcludedMmFreePageFromMdl/2;

  predicate sourceSinkIsRelated = defaultSourceSinkIsRelated/2;
}

import UseAfterFreeParam

module UseAfterFreeTrace = FlowFromFree<UseAfterFreeParam>;

class FreeAddrInfo extends DeallocationExpr,FunctionCall {
   
    FreeAddrInfo() {
        this.getTarget().hasGlobalName("freeaddrinfo")
    }

    override Expr getFreedExpr(){
        result = this.getArgument(0)
    }
}


from UseAfterFreeTrace::PathNode source, UseAfterFreeTrace::PathNode sink, FreeAddrInfo dealloc
where
  UseAfterFreeTrace::flowPath(source, sink) and
  isFree(source.getNode(), _, _, dealloc)
select sink.getNode(), source, sink, "Memory may have been previously freed by $@.", dealloc,
  dealloc.toString()

I'm trying to analyse https://nvd.nist.gov/vuln/detail/CVE-2021-38383

@tardigrade-9 tardigrade-9 added the question Further information is requested label Mar 5, 2024
@sidshank sidshank added the C++ label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants