Skip to content

Commit 2d6045d

Browse files
committed
Fix SSRF in imsBaseURL and clear ExtraData in integration test
1 parent d868eb9 commit 2d6045d

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

pkg/detectors/adobeims/adobeims.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ var (
3636

3737
// Matches any JWT; Adobe IMS tokens are identified by decoding the payload and checking the "as" field.
3838
jwtPat = regexp.MustCompile(`(eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,})`)
39+
40+
// imsRegionPat validates the "as" field from the JWT payload before interpolating it into a URL.
41+
// Prevents SSRF via crafted values like "ims-x@evil.com/".
42+
imsRegionPat = regexp.MustCompile(`^ims-[a-z0-9]+$`)
3943
)
4044

4145

@@ -96,6 +100,9 @@ func decodeJWTPayload(token string) (*jwtPayload, error) {
96100

97101

98102
func imsBaseURL(as string) string {
103+
if !imsRegionPat.MatchString(as) {
104+
return "https://ims-na1.adobelogin.com"
105+
}
99106
return fmt.Sprintf("https://%s.adobelogin.com", as)
100107
}
101108

pkg/detectors/adobeims/adobeims_integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func TestAdobeIMS_FromData(t *testing.T) {
9696
t.Fatalf("no raw secret present: \n %+v", got[i])
9797
}
9898
got[i].Raw = nil
99+
got[i].ExtraData = nil
99100
}
100101
if diff := pretty.Compare(got, tt.want); diff != "" {
101102
t.Errorf("AdobeIMS.FromData() %s diff: (-got +want)\n%s", tt.name, diff)

0 commit comments

Comments
 (0)