-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from cerberauth/discover-well-known-paths
Discover Well-Known paths and leaked files
- Loading branch information
Showing
17 changed files
with
1,360 additions
and
101 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,38 @@ | ||
package exposedfiles | ||
|
||
import ( | ||
"github.com/cerberauth/vulnapi/internal/auth" | ||
"github.com/cerberauth/vulnapi/internal/operation" | ||
"github.com/cerberauth/vulnapi/report" | ||
"github.com/cerberauth/vulnapi/scan/discover" | ||
) | ||
|
||
const ( | ||
DiscoverableFilesScanID = "discover.exposed_files" | ||
DiscoverableFilesScanName = "Discoverable exposed files" | ||
) | ||
|
||
type DiscoverableFilesData = discover.DiscoverData | ||
|
||
var issue = report.Issue{ | ||
ID: "discover.exposed_files", | ||
Name: "Discoverable exposed files", | ||
|
||
Classifications: &report.Classifications{ | ||
OWASP: report.OWASP_2023_SSRF, | ||
}, | ||
|
||
CVSS: report.CVSS{ | ||
Version: 4.0, | ||
Vector: "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:N/SA:N", | ||
Score: 0, | ||
}, | ||
} | ||
|
||
var discoverableFilesSeclistUrl = "https://raw.githubusercontent.com/cerberauth/vulnapi/main/seclist/lists/exposed-paths.txt" | ||
|
||
func ScanHandler(op *operation.Operation, securityScheme *auth.SecurityScheme) (*report.ScanReport, error) { | ||
vulnReport := report.NewIssueReport(issue).WithOperation(op).WithSecurityScheme(securityScheme) | ||
r := report.NewScanReport(DiscoverableFilesScanID, DiscoverableFilesScanName, op) | ||
return discover.DownloadAndScanURLs("Exposed Files", discoverableFilesSeclistUrl, r, vulnReport, op, securityScheme) | ||
} |
This file contains 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,50 @@ | ||
package exposedfiles_test | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/cerberauth/vulnapi/internal/auth" | ||
"github.com/cerberauth/vulnapi/internal/operation" | ||
"github.com/cerberauth/vulnapi/internal/request" | ||
exposedfiles "github.com/cerberauth/vulnapi/scan/discover/exposed_files" | ||
"github.com/jarcoal/httpmock" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDiscoverableScanner_Passed_WhenNoDiscoverableGraphqlPathFound(t *testing.T) { | ||
client := request.NewClient(request.NewClientOptions{ | ||
RateLimit: 500, | ||
}) | ||
httpmock.ActivateNonDefault(client.Client) | ||
defer httpmock.DeactivateAndReset() | ||
|
||
op := operation.MustNewOperation(http.MethodGet, "http://localhost:8080/", nil, client) | ||
httpmock.RegisterResponder(op.Method, op.URL.String(), httpmock.NewBytesResponder(http.StatusNoContent, nil)) | ||
httpmock.RegisterNoResponder(httpmock.NewBytesResponder(http.StatusNotFound, nil)) | ||
|
||
report, err := exposedfiles.ScanHandler(op, auth.MustNewNoAuthSecurityScheme()) | ||
|
||
require.NoError(t, err) | ||
assert.Greater(t, httpmock.GetTotalCallCount(), 7) | ||
assert.True(t, report.Issues[0].HasPassed()) | ||
} | ||
|
||
func TestDiscoverableScanner_Failed_WhenOneGraphQLPathFound(t *testing.T) { | ||
client := request.NewClient(request.NewClientOptions{ | ||
RateLimit: 500, | ||
}) | ||
httpmock.ActivateNonDefault(client.Client) | ||
defer httpmock.DeactivateAndReset() | ||
|
||
operation := operation.MustNewOperation(http.MethodGet, "http://localhost:8080/.aws/credentials", nil, client) | ||
httpmock.RegisterResponder(operation.Method, operation.URL.String(), httpmock.NewBytesResponder(http.StatusOK, nil)) | ||
httpmock.RegisterNoResponder(httpmock.NewBytesResponder(http.StatusNotFound, nil)) | ||
|
||
report, err := exposedfiles.ScanHandler(operation, auth.MustNewNoAuthSecurityScheme()) | ||
|
||
require.NoError(t, err) | ||
assert.Greater(t, httpmock.GetTotalCallCount(), 0) | ||
assert.True(t, report.Issues[0].HasFailed()) | ||
} |
This file contains 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.