Repository navigation
bug: block Zip Slip in /import extraction and upgrade adm-zip to 0.6.1 (sfind-43966ddb) - #1105
Open
devin-ai-integration[bot] wants to merge 10 commits into
Open
devin-ai-integration[bot] wants to merge 10 commits into
devin-ai-integration[bot] wants to merge 10 commits into
Conversation
…rt (sfind-ed54b459) Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…O errors Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…entries before writing Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…er-entry Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…zip 0.6 (sfind-43966ddb) Refs sfind-43966ddb
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
… (sfind-43966ddb)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Corrige o Zip Slip (finding
sfind-43966ddb, crítico) emexports.import(routes/index.js:247-257):zip.extractAllTo('/tmp/extracted_files', true)com adm-zip 0.4.7 faziapath.resolve(target, entryName)sem checar../, então um zip anônimo com../../usr/src/goof/routes/index.jssobrescrevia arquivos do servidor.Duas camadas:
utils.safeExtractZip(zip, targetDir)):ZIP_ENTRY_OUTSIDE_TARGET/ZIP_INVALID_ARCHIVE(e erro noAdmZip(buffer)) ->400 Invalid archive.; outros erros ->next(err).package.json+package-lock.jsoncom integridade sha512), que também traz a checagem de path traversal/symlink da própria lib.Commits novos neste PR: (a) uma entrada de diretório
./(resolve para o próprioroot) é aceita, mas só se for diretório; (b) o adm-zip 0.6.x lê o diretório central de forma preguiçosa, então um zip corrompido lança emgetEntries(). Isso agora viraZIP_INVALID_ARCHIVE(400) em vez de 500.Contrato de API:
POST /importcom zip malicioso ou corrompido agora retorna400 Invalid archive.. Antes, o zip malicioso retornava 302 e gravava o arquivo; o corrompido retornava 500 (ou 302 com CRC inválido). Zips válidos e a importação de texto continuam retornando 302.Fora do escopo: o finding também recomenda autenticação em
/import. Não adicionei, porque o formulário de importação da página inicial é usado por visitantes anônimos e isso mudaria o fluxo do app. A correção de Zip Slip acima não depende disso.Duplicado: os 6 commits de #1075 (sfind-ed54b459) e os 2 commits de adm-zip de #1074 (sfind-91ffb09a) foram aplicados com cherry-pick, mais o commit do item acima. Abri um PR novo para este finding pela regra de um ticket por PR. Só um destes PRs deve ser mergeado (#1075/#1079/#1074/#1082 se sobrepõem).
Como testar
App real (
NODE_OPTIONS=--openssl-legacy-provider node app.js, mongod local) +curl -F importFile=@x.zip;type=application/zip localhost:PORT/import:../../home/ubuntu/goof4396-target/routes/index.js/* PWNED by zip slip */)../ed54-pwned.txt/tmp/ed54-pwned.txtcriadobackup.txt,sub/dir/note.txt)./+./backup.txtO código deste branch também foi testado com adm-zip 0.4.7: a PoC retorna 400 e o alvo fica intacto, então a validação protege mesmo sem o upgrade.
Não há suíte de testes automatizada:
npm testésnyk teste precisa de auth.Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/082d863792ed495698cd6559cdcac597
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/082d863792ed495698cd6559cdcac597?variant=devin
Devin Review