client_secret_basic: applyBasicAuth base64-encodes raw credentials instead of form-encoding each half (RFC 6749 §2.3.1)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- authentication, backend
Línea de trabajo
Read packages/client/src/client/auth.ts at applyBasicAuth and the linked issue #3039, which already has an open pull request for this fix. The issue describes the credential encoding cases and expected behavior; compare the existing tests and pull request changes to see what remains to be done.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What's broken
applyBasicAuth (packages/client/src/client/auth.ts:880 on main) sends the client id and secret to the Authorization header without the per-half encoding that RFC 6749 §2.3.1 requires:
const credentials = btoa(`${clientId}:${clientSecret}`);
headers.set('Authorization', `Basic ${credentials}`);
§2.3.1 says the client must form-encode client_id and client_secret before joining them with :, and the token endpoint base64-decodes, splits on the first :, then form-decodes each half. Sending the raw values means the server recovers different credentials than the client intended:
| client_id / client_secret sent | server recovers | problem |
|---|---|---|
cid / a+b |
username cid, password `a b` |
+ decodes as a space |
client id / sec:ret+with=special |
username client, password id:sec:ret with=special |
: in the id splits at the wrong place, + turns into a space |
cid / p€ss |
— | btoa throws InvalidCharacterError before any request is sent |
cid / 50%off |
— | % alone is not valid form encoding; strict servers fail to decode |
Only credentials made of unreserved characters are unaffected.
Repro
Any client_secret_basic flow with a secret containing +, %, =, /, a client id containing :, or a non-Latin-1 character. To see the server-side recovery without a live IdP:
// What the client sends today
const auth = `Basic ${Buffer.from('cid:a+b').toString('base64')}`;
const raw = Buffer.from(auth.slice('Basic '.length), 'base64').toString();
// What a conformant token endpoint does next (RFC 6749 §2.3.1)
const idx = raw.indexOf(':');
const decode = s => new URLSearchParams(`v=${s}`).get('v');
decode(raw.slice(idx + 1)); // 'a b' — expected 'a+b'
Expected
Encode each half before concatenation, e.g. encodeURIComponent with the !'()* set escaped (matching the Python SDK's quote(value, safe=""), which leaves ~ raw so Entra-style Q~… secrets stay byte-identical), so the server recovers exactly the configured values.
Scope
The same code exists on the v1.x branch (src/client/auth.ts:358). I've opened #3039 with a fix and tests for main and can send the v1.x equivalent if you want it.
Disclosure per the AI contribution policy: this issue was written with Claude Code (an AI coding assistant) under my direction, based on a bug I verified locally against the code above; the reproduction and the RFC citation were checked by hand.
- Lenguaje dominante
- TypeScript
- Estrellas
- 13.8k
- Forks
- 2.5k
- Merge medio
- 6 d 23 h
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/typescript-sdk
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
modelcontextprotocol/typescript-sdk#3270 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`Posiblemente ocupada @mgoldsborough la tomó hace 6 días. Abiertov2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
modelcontextprotocol/typescript-sdk#3249 ·
Los mantenedores suelen responder en 1 día
-
v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
modelcontextprotocol/typescript-sdk#3243 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` replyPosiblemente ocupada @Tidehyc la tomó hace 7 días. Abiertov2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
modelcontextprotocol/typescript-sdk#3235 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
UriTemplate.match() throws a TypeError on an empty expression it acceptsPosiblemente ocupada @yunusemrejs la tomó hace 12 días. Abiertov1 v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
modelcontextprotocol/typescript-sdk#3221 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/typescript-sdk
Issues similares
-
clawsweeper:intake:bug clawsweeper:intake:needs-environment
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
openclaw/openclaw#212827 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
KT-2245 e2e specs that call the backend directly fall back to the developer's own Kronn on :3140Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Use one constant for the 10,000-character input limitPosiblemente ocupada @NginxL la tomó hoy. Abiertogood first issue refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
aniru-dh21/snap-validate#51 ·
Los mantenedores suelen responder en 1 día
-
dependencies effort: small good first issue priority: low
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
TMHSDigital/screencast-mcp#509 ·
Los mantenedores suelen responder en 1 día
-
from-review tech-debt testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
blamechris/chroxy#9520 ·
Los mantenedores suelen responder en 1 día