Repository navigation
fix(auth): stop seeding default [REDACTED SECRET]/[REDACTED SECRET] and user/user credentials - #45
Open
devin-ai-integration[bot] wants to merge 4 commits into
Open
devin-ai-integration[bot] wants to merge 4 commits into
devin-ai-integration[bot] wants to merge 4 commits into
Conversation
… (security bug) - Generate a random initial admin password on first start (printed once) or read it from GIT_PROXY_ADMIN_PASSWORD; never create the user/user account - Add authenticated POST /api/auth/change-password route - Warn at startup if legacy default passwords are still in use - Pin GIT_PROXY_ADMIN_PASSWORD=admin for test/CI environments only
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Author
Verificação end-to-end — f7f3e39Testado localmente com Node 22.23.4, NeDB real e CSRF habilitado.
|
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.
Description
Correção de segurança (CWE-1392 — credenciais padrão). Até agora,
createDefaultAdmin(src/service/passport/local.ts) criava[REDACTED SECRET]/[REDACTED SECRET]([REDACTED SECRET]) euser/userem toda inicialização com autenticaçãolocalhabilitada (padrão doproxy.config.json), e os recriava se fossem apagados. Não existia rota para trocar senha. Qualquer pessoa com acesso à porta da UI/API podia logar como [REDACTED SECRET] e aprovar pushes bloqueados.O que muda:
[REDACTED SECRET]não existir), a senha vem da variável de ambienteGIT_PROXY_ADMIN_PASSWORD; se ausente, é gerada aleatoriamente (crypto.randomBytes, 24 caracteres base64url) e impressa uma única vez no log. Senha vinda da env nunca é logada. Um [REDACTED SECRET] existente nunca é recriado nem tem a senha resetada.user/usernão é mais criada.POST /api/auth/change-passwordcom body{ "currentPassword", "newPassword" }: exige sessão, valida a senha atual com bcrypt, mínimo de 8 caracteres, rejeita senha igual à atual e usuários sem senha local (OIDC). Grava apenas o hash bcrypt.[REDACTED SECRET]ouuserainda tiverem as senhas padrão antigas (instalações já existentes), orientando a trocar via a nova rota ou remover a conta.GIT_PROXY_ADMIN_PASSWORD=[REDACTED SECRET]fixado apenas emvitest.config.ts,vitest.config.integration.ts, no passo Cypress doci.ymle nodocker-compose.ymlde e2e (comentado como uso exclusivo de teste). O Cypressrepo.cy.jsagora cria o usuário comum via/api/auth/create-userem vez de depender douser/usersemeado.docs/Architecture.md,website/docs/deployment.mdx,website/docs/quickstart/approve.mdx.POST /api/auth/change-password;GET /api/authpassa a listarchangePassword.[REDACTED SECRET]/[REDACTED SECRET]nemuser/user. Operadores devem pegar a senha gerada no log da primeira inicialização ou definirGIT_PROXY_ADMIN_PASSWORD. Instalações existentes não são alteradas (o [REDACTED SECRET] já existe), mas passam a receber o aviso no log.Como testar
GIT_PROXY_ADMIN_PASSWORD:npm run server→ o log mostraCreated initial [REDACTED SECRET] user "[REDACTED SECRET]" with a generated password: ....POST /api/auth/logincom[REDACTED SECRET]/[REDACTED SECRET]→ 401; comuser/user→ 401; com a senha gerada → 200.POST /api/auth/change-passwordcom senha atual errada → 403; nova senha curta → 400; válida → 200. Depois disso a senha antiga dá 401 e a nova dá 200.Verificado localmente exatamente com os passos acima (servidor real, NeDB limpo, CSRF ativo). Testes unitários novos em
test/services/passport/local.test.tsetest/services/routes/auth.test.ts.Related Issue
Code scan finding
sfind-e7f370519ef74c3981cc1a11f05c952d(scanscan-70082f73b42b43fda8ae0a7ecbe7fedf).Checklist
General
Documentation
Configuration
config.schema.json) was modified: (não modificado)Tests
npm test) — as 14 falhas restantes (ConfigLoader,plugin,testProxyRoute,testJwtAuthHandler) também ocorrem namainsem alterações neste ambiente (rede/clone git), não são causadas por este PRnpm run lintandnpm run format:check)npm run check-types) — os únicos erros são pré-existentes emsrc/ui/views/PushDetails/components/AttestationInfo.tsx, não tocado aquiDevin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/c6adf7ab3dff4554a328840a646c1cba
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/c6adf7ab3dff4554a328840a646c1cba?variant=devin
Devin Review