-
Notifications
You must be signed in to change notification settings - Fork 147
fix: support comma-separated items in list file (issue #859) #965
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
FraktalDeFiDAO
wants to merge
5
commits into
projectdiscovery:main
from
FraktalDeFiDAO:fix/comma-separated-list-in-file
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d655aef
fix: prevent indefinite hang in TLSX during large-scale scans (#819)
6af3f4b
fix: address review feedback and resolve ARM64 deadlock
7d42730
chore: root CA update :robot:
ghost 8ca7168
fix: support comma-separated items in list file (closes #859)
FraktalDeFiDAO 80de3b4
fix: address CodeRabbit critical issues - TLS config race condition a…
FraktalDeFiDAO 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,77 @@ | ||
| name: Go Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| matrix: | ||
| go: ['1.21', '1.22', '1.23'] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ matrix.go }} | ||
| cache: true | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Run tests | ||
| run: go test -v -race -coverprofile=coverage.out ./... | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| file: ./coverage.out | ||
| flags: unittests | ||
|
|
||
| build: | ||
| runs-on: ubuntu-latest | ||
| needs: test | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.23' | ||
|
|
||
| - name: Build | ||
| run: go build -v ./... | ||
|
|
||
| - name: Build binary | ||
| run: go build -o tlsx ./cmd/tlsx/ | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: tlsx-binary | ||
| path: tlsx | ||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.23' | ||
|
|
||
| - name: Run golangci-lint | ||
| uses: golangci/golangci-lint-action@v4 | ||
| with: | ||
| version: latest | ||
| args: --timeout=5m |
Large diffs are not rendered by default.
Oops, something went wrong.
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,67 @@ | ||
| package pdcp_test | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "sync" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/projectdiscovery/tlsx/pkg/tlsx/clients" | ||
| "github.com/projectdiscovery/tlsx/internal/pdcp" | ||
| pdcpauth "github.com/projectdiscovery/utils/auth/pdcp" | ||
| ) | ||
|
|
||
| func TestUploadWriterExploit(t *testing.T) { | ||
| creds := &pdcpauth.PDCPCredentials{ | ||
| Server: "http://localhost:8080", | ||
| APIKey: "test-key", | ||
| } | ||
|
|
||
| // Use a longer timeout to allow the race to manifest | ||
| ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) | ||
| defer cancel() | ||
|
|
||
| writer, err := pdcp.NewUploadWriterCallback(ctx, creds) | ||
| if err != nil { | ||
| t.Fatalf("failed to create writer: %v", err) | ||
| } | ||
|
|
||
| var wg sync.WaitGroup | ||
| callback := writer.GetWriterCallback() | ||
|
|
||
| // Exploit Layer 1: Hammer the string headers with different lengths to trigger tearing | ||
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() | ||
| for i := 0; i < 100000; i++ { | ||
| // Alternating lengths is key to triggering pointer/length tearing | ||
| if i % 2 == 0 { | ||
| writer.SetAssetID("short-id") | ||
| } else { | ||
| writer.SetAssetID("very-long-asset-group-identifier-that-exceeds-small-string-optimization") | ||
| } | ||
| } | ||
| }() | ||
|
|
||
| // Exploit Layer 2: High-pressure concurrent writes | ||
| for g := 0; g < 20; g++ { | ||
| wg.Add(1) | ||
| go func(id int) { | ||
| defer wg.Done() | ||
| for i := 0; i < 5000; i++ { | ||
| callback(&clients.Response{ | ||
| Host: fmt.Sprintf("target-%d-%d.com", id, i), | ||
| Port: "443", | ||
| }) | ||
| } | ||
| }(g) | ||
| } | ||
|
|
||
| fmt.Println("Exploit running: Hammering ARM64 memory model...") | ||
| wg.Wait() | ||
|
|
||
| fmt.Println("Attempting final close (Expect hang or crash here)...") | ||
| writer.Close() | ||
| fmt.Println("SUCCESS: Writer closed (Vulnerability NOT triggered).") | ||
| } | ||
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
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
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
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.
The deadline can deadlock this test under backpressure.
In
internal/pdcp/writer.go,autoCommit()stops consumingu.datawhenctx.Done()fires, but this test waits for all sender goroutines before callingwriter.Close(). If the 20s deadline expires first—or something onlocalhost:8080is slow instead of refusing fast—the callback goroutines can block forever on channel sends andwg.Wait()never returns.🧪 Suggested follow-up
Also applies to: 47-65
🤖 Prompt for AI Agents