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

GO - Add sink for libxml2 in go/xml/xpath-injection via XPath.qll #15181

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

felickz
Copy link
Contributor

@felickz felickz commented Dec 20, 2023

Add support for XXE sinks via the libxml2 package for Parse/ParseString/ParseReader

Changes

  • Introduce a new class LestratGoLibxml2XPathExpressionString to the XPath module in the go/ql/lib/semmle/go/frameworks/XPath.qll file.
  • This class is designed to handle XPath expression strings used in the Parser API functions of the lestrrat-go/libxml2 package.
  • The class identifies the function with the Parse% naming pattern within the github.com/lestrrat-go/libxml2/parser.Parser package and assigns the first argument of the function call as an instance of this class.
  • Added changelog (view md)

Testing:

  • Install depstubber at go/ql/test
PATH="$PATH:$GOPATH/bin" 
GO111MODULES=off go get github.com/github/depstubber
GO111MODULES=off go install github.com/github/depstubber
  • Generate Stubs: depstubber -vendor github.com/lestrrat-go/libxml2/parser Parser New,XMLParseNoEnt
  • Succeeds: go build ./...
  • edges/nodes as expected in testresults

felickz and others added 3 commits December 12, 2023 15:00
- Sample test  (test not compiling)
- Stubs not generating
@github-actions github-actions bot added the Go label Dec 20, 2023
felickz and others added 4 commits December 21, 2023 00:23
(it will automatically make stubs for all the methods on that type)

Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
- still failing with ./tst.go:195:25: undefined: parser.XMLParseNoEnt
| tst.go:152:14:152:35 | call to Get | tst.go:164:31:164:126 | ...+... |
| tst.go:152:14:152:35 | call to Get | tst.go:173:21:173:116 | ...+... |
| tst.go:152:14:152:35 | call to Get | tst.go:182:27:182:122 | ...+... |
| tst.go:193:14:193:19 | selection of Form | tst.go:193:14:193:35 | call to Get |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

| tst.go:164:31:164:126 | ...+... | semmle.label | ...+... |
| tst.go:173:21:173:116 | ...+... | semmle.label | ...+... |
| tst.go:182:27:182:122 | ...+... | semmle.label | ...+... |
| tst.go:193:14:193:19 | selection of Form | semmle.label | selection of Form |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

owen-mc
owen-mc previously approved these changes Dec 21, 2023
@felickz felickz marked this pull request as ready for review December 22, 2023 16:57
@felickz felickz requested a review from a team as a code owner December 22, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants