Skip to content

bug: fix ReDoS in todo reminder and import date parsing (sfind-4c4caf56) - #1107

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/sfind-4c4caf56-todo-import-redos
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/sfind-4c4caf56-todo-import-redos

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

Corrige o finding de Code Scan sfind-4c4caf56 (low): ReDoS no parsing de lembrete dos todos e no import CSV de routes/index.js. Um POST /create anônimo com x in + uma longa sequência de dígitos fazia humanize-ms/ms 0.7.x rodar em tempo quadrático e bloqueava o event loop para todos os usuários.

  • package.json / package-lock.json: humanize-ms 1.0.1 -> 1.2.1, ms ^0.7.1 (0.7.3) -> 2.1.3, moment 2.15.1 -> 2.29.4 (o ms 2.x ignora strings com mais de 100 chars; cópias aninhadas de ms 2.1.x foram deduplicadas).
  • routes/index.js: novo MAX_PARSE_LENGTH = 1000. Acima disso o texto é salvo sem passar pelos parsers:
    // parse(todo)
    if (typeof t !== 'string' || t.length > MAX_PARSE_LENGTH) return t;
    var period = time ? hms(time) : undefined;   // ms 2.x lança erro com string vazia ("comprar leite in ")
    // create: imgRegex só roda em item.length <= MAX_PARSE_LENGTH (um único match)
    // import: moment.locale/moment()/format() só para line.length <= MAX_PARSE_LENGTH
  • Sem mudança de contrato de API: as rotas continuam respondendo igual (302); um todo/linha longa é salvo como texto puro, sem o sufixo [...].

Sobreposição: o PR #1069 (sfind-39400a20) também sobe moment para 2.29.4. Se os dois forem mergeados, o segundo só precisa resolver o conflito no package-lock.json.

Como testar

Rodei o app real (node app.js; o Mongo foi trocado por um stub em memória porque o mongod local não fala com mongoose 4.2.4) em main e nesta branch, via curl:

main este PR
"buy milk in 2d" / "call mom in 90 minutes" buy milk [2d] / call mom [2h] igual
"buy milk in " / "pay rent in soon" buy milk / pay rent igual (sem 500)
todo de imagem ![alt text](http://… "t") found img: http://… igual
POST /create x in +1x5000/20000/50000+x 0.09 s / 1.3 s / 8.7 s 0.002 s / 0.002 s / 0.002 s
GET /about_new concorrente com o payload de 50 KB 9.7 s (event loop bloqueado) 0.007 s
imgRegex com 48 KB (![alt text](http x3000) 0.09 s 0.004 s
import CSV dentist,2016-10-01,en,LL + linha de 50 KB dentist [October 1, 2016] igual; linha longa salva sem data

Probe direto nas libs (hms('1'.repeat(n)+'x'), n = 5k/20k/50k): 115 / 1497 / 8589 ms -> 0.3 / 0.1 / 0.2 ms.

Fora do escopo: GET / continua levando ~3-4 s quando há todos de 50 KB salvos, por causa do marked@0.3.5 na renderização (finding separado, PRs #1077/#1088). npm test (snyk test) não roda aqui (sem token Snyk).

Devin-Org: engineering

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/7690f99bb02549b799870d7135f24577
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/7690f99bb02549b799870d7135f24577?variant=devin


Devin Review

Status Commit
⚪ Not started —

Run Devin Review

Enable auto-review to review your pull requests automatically.

Devin Review (Staging)


Devin Review

Upgrade humanize-ms 1.0.1 -> 1.2.1, ms 0.7.3 -> 2.1.3 and moment 2.15.1 ->
2.29.4, and skip reminder parsing, imgRegex matching and import date
formatting for input longer than 1000 characters. Guard the empty period
("... in ") since ms 2.x throws on an empty string.

Refs: sfind-4c4caf5662bf4bfc99fc567c8b99355b
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedhumanize-ms@​1.0.1 ⏵ 1.2.110010073 -581100
Updatedmoment@​2.15.1 ⏵ 2.29.410099 +219188100

View full report

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants