fix(security): guard EPG XML importer against oversized text nodes#602
fix(security): guard EPG XML importer against oversized text nodes#602Bladestar2105 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73b804f7ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const appendText = (text) => { | ||
| if (currentChannel && currentTag === 'display-name') { | ||
| if (currentText.length + text.length > MAX_XML_TEXT_NODE_LENGTH) { |
There was a problem hiding this comment.
Apply text-size cap only to tracked XML node content
The new guard runs before checking whether we are inside display-name, title, or desc, so it uses stale currentText from a previous tracked node when handling later text events. This causes false rejections: a title just under 50KB can still fail when a subsequent non-tracked text node (for example <category>) is parsed, because the condition compares that new text against the previous node’s accumulated length. Move the size check inside the same branches that append to currentText (or reset currentText on every text-bearing tag) so the cap is truly per-node.
Useful? React with 👍 / 👎.
Motivation
display-name,title, anddescwithout any per-node size limit, enabling a remote provider to cause unbounded memory growth and a DoS.Description
MAX_XML_TEXT_NODE_LENGTH = 50 * 1024to the streaming parser insrc/services/epgService.js.appendTexthandler and abort the import by rejecting the parser promise, callingstream.destroy(), and closing the parser when the limit is exceeded.display-name,title, anddescwhile preserving the existing GZIP handling, streamingnode-xml-streamflow, and batch DB insertion logic.Testing
npm run lint, which completed successfully and reported only pre-existing warnings.npm test -- epgService, which found no matching tests in the repository.npm run build, which completed successfully.Codex Task