Skip to content

Commit 155c6ad

Browse files
authored
fix: Server-Side Request Forgery (SSRF) in Instagram auth adapter [GHSA-3f5f-xgrj-97pf](GHSA-3f5f-xgrj-97pf) (#9989)
1 parent 0b032a3 commit 155c6ad

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

spec/Adapters/Auth/instagram.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,31 @@ describe('InstagramAdapter', function () {
101101
'Instagram auth is invalid for this user.'
102102
);
103103
});
104+
105+
it('should ignore client-provided apiURL and use hardcoded endpoint', async () => {
106+
const accessToken = 'mockAccessToken';
107+
const authData = {
108+
id: 'mockUserId',
109+
apiURL: 'https://example.com/',
110+
};
111+
112+
mockFetch([
113+
{
114+
url: 'https://graph.instagram.com/me?fields=id&access_token=mockAccessToken',
115+
method: 'GET',
116+
response: {
117+
ok: true,
118+
json: () =>
119+
Promise.resolve({
120+
id: 'mockUserId',
121+
}),
122+
},
123+
},
124+
]);
125+
126+
const user = await adapter.getUserFromAccessToken(accessToken, authData);
127+
expect(user).toEqual({ id: 'mockUserId' });
128+
});
104129
});
105130

106131
describe('InstagramAdapter E2E Test', function () {

src/Adapters/Auth/instagram.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ class InstagramAdapter extends BaseAuthCodeAdapter {
9696
}
9797

9898
async getUserFromAccessToken(accessToken, authData) {
99-
const defaultURL = 'https://graph.instagram.com/';
100-
const apiURL = authData.apiURL || defaultURL;
99+
const apiURL = 'https://graph.instagram.com/';
101100
const path = `${apiURL}me?fields=id&access_token=${accessToken}`;
102101

103102
const response = await fetch(path);

0 commit comments

Comments
 (0)