Title: Go: Tainted data does not propagate data flow after append function · Issue #14116 · github/codeql · GitHub
Open Graph Title: Go: Tainted data does not propagate data flow after append function · Issue #14116 · github/codeql
X Title: Go: Tainted data does not propagate data flow after append function · Issue #14116 · github/codeql
Description: Go: v1.19.1 linux/amd64 CodeQL: v2.11.0 Question: Query the data flow results from the input parameter in the source function to the name parameter in the sink function. package main import ( "fmt" ) type info struct { name string } func...
Open Graph Description: Go: v1.19.1 linux/amd64 CodeQL: v2.11.0 Question: Query the data flow results from the input parameter in the source function to the name parameter in the sink function. package main import ( "fmt"...
X Description: Go: v1.19.1 linux/amd64 CodeQL: v2.11.0 Question: Query the data flow results from the input parameter in the source function to the name parameter in the sink function. package main import ( "...
Opengraph URL: https://github.com/github/codeql/issues/14116
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Go: Tainted data does not propagate data flow after append function","articleBody":"Go: v1.19.1 linux/amd64\r\nCodeQL: v2.11.0\r\n\r\nQuestion: Query the data flow results from the `input` parameter in the `source` function to the `name` parameter in the `sink` function.\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n)\r\n\r\ntype info struct {\r\n\tname string\r\n}\r\nfunc main() {\r\n\tsource(\"input\")\r\n}\r\n\r\nfunc source(input string) {\r\n\tvar data []info\r\n\tdata = append(data, info{\r\n\t\tname: input,\r\n\t})\r\n\tdao(data)\r\n\r\n}\r\n\r\nfunc dao(data []info) {\r\n\tfor _, item := range data {\r\n\t\tname := item.name\r\n\t\tsink(name)\r\n\t}\r\n}\r\n\r\nfunc sink(name string) {\r\n\tfmt.Println(name)\r\n}\r\n\r\n```\r\n\r\n\r\nThe following is my query statement. After execution, I did not get the expected results.\r\n\r\n\u003cimg width=\"1828\" alt=\"append_struct_result\" src=\"https://github.com/github/codeql/assets/48125429/bd01e325-adc9-4187-8e6e-1b60c7542d91\">\r\n\r\n\r\n```codeql\r\n/**\r\n * @kind path-problem\r\n */\r\n\r\nimport go\r\nimport DataFlow::PathGraph\r\n\r\nclass Configuration extends TaintTracking::Configuration {\r\n Configuration() { this = \"Configuration\" }\r\n\r\n override predicate isSource(DataFlow::Node source) {\r\n exists(Function func | func.getName() = \"source\" | func.getParameter(0) = source.asParameter())\r\n }\r\n\r\n override predicate isSink(DataFlow::Node sink) {\r\n exists(DataFlow::CallNode call | call.getTarget().getName() = \"sink\" |\r\n call.getArgument(0) = sink\r\n )\r\n }\r\n}\r\n\r\nfrom Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink\r\nwhere cfg.hasFlowPath(source, sink)\r\nselect sink.getNode(), source, sink, \"Source: $@ , Sink: $@ .\", source.getNode(), source.toString(),\r\n sink.getNode(), sink.toString()\r\n```\r\n\r\n\r\nWhen I debug using `DataFlow::PartialPathGraph`, it seems that the tainted data does not propagate the data flow after passing through the `append` function.\r\n\r\n\u003cimg width=\"1797\" alt=\"append_struct_partial\" src=\"https://github.com/github/codeql/assets/48125429/f2365c7b-2bff-4e0e-83ad-9c669e49cb05\">\r\n\r\n\r\n```codeql\r\n/**\r\n * @kind path-problem\r\n */\r\n\r\nimport go\r\nimport DataFlow::PartialPathGraph\r\n\r\nclass Configuration extends TaintTracking::Configuration {\r\n Configuration() { this = \"Configuration\" }\r\n\r\n override predicate isSource(DataFlow::Node source) {\r\n exists(Function func | func.getName() = \"source\" | func.getParameter(0) = source.asParameter())\r\n }\r\n\r\n override predicate isSink(DataFlow::Node sink) {\r\n exists(DataFlow::CallNode call | call.getTarget().getName() = \"sink\" |\r\n call.getArgument(0) = sink\r\n )\r\n }\r\n\r\n override int explorationLimit() { result = 5 }\r\n}\r\n\r\nfrom Configuration cfg, DataFlow::PartialPathNode source, DataFlow::PartialPathNode sink\r\nwhere cfg.hasPartialFlow(source, sink, _)\r\nselect sink.getNode(), source, sink, \"Source: $@ , Sink: $@ .\", source.getNode(), source.toString(), sink.getNode(), sink.toString()\r\n```\r\n\r\n\r\nHow to solve this problem?\r\n\r\n\r\n","author":{"url":"https://github.com/Jokuuy","@type":"Person","name":"Jokuuy"},"datePublished":"2023-09-01T03:42:17Z","url":"https://github.com/github/codeql/issues/14116"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0e1c2804-c8b4-37d4-5253-9923aa186216 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA98:3CC0D9:89209F:BC46DA:6AF85B24 |
| html-safe-nonce | 309e6e7bbb57fe081fe3e485ff83e1fe6b08411ac382e6ef7aac7ac809695d32 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTk4OjNDQzBEOTo4OTIwOUY6QkM0NkRBOjZBRjg1QjI0IiwidmlzaXRvcl9pZCI6IjYzMTYxMTgzNzgzMTgxNTg2MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bee854229f9518528bcdc850a042fef56d9a0c88e47c137675d0d88fa9d6449c |
| hovercard-subject-tag | issue:1876663748 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/codeql/14116/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4e5d72230b09e6051fb9d8c6eea14d691159f230d328f70e82ee34b08b9919aa/github/codeql/issues/14116 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4e5d72230b09e6051fb9d8c6eea14d691159f230d328f70e82ee34b08b9919aa/github/codeql/issues/14116 |
| og:image:alt | Go: v1.19.1 linux/amd64 CodeQL: v2.11.0 Question: Query the data flow results from the input parameter in the source function to the name parameter in the sink function. package main import ( "fmt"... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jokuuy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| go-import | github.com/github/codeql git https://github.com/github/codeql.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 143040428 |
| octolytics-dimension-repository_nwo | github/codeql |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 143040428 |
| octolytics-dimension-repository_network_root_nwo | github/codeql |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width