client_secret.json without project_id: silent fallback to ambient gcloud ADC quota_project_id escapes CONFIG_DIR isolation
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- rust
- Ambito
- authentication, cli
Direzione di ricerca
Start by tracing quota-project resolution from the binding's client_secret.json to the ambient application_default_credentials.json, using the raw Discovery call in the reproduction as the entry point. Add a regression check for a missing project_id with ADC quota_project_id present, and verify that the binding does not use the ambient project and follows one of the stated expected behaviors.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
When client_secret.json has no project_id field, gws does not omit the x-goog-user-project quota project — it silently falls back to the ambient gcloud ADC quota_project_id read from ~/.config/gcloud/application_default_credentials.json.
Two problems:
- It escapes
GOOGLE_WORKSPACE_CLI_CONFIG_DIRisolation. The whole point of pointingCONFIG_DIRat a self-contained directory is that the binding is defined by that directory. Instead gws reaches outside it into machine-global gcloud state that the user never associated with this binding. - It fails confusingly. The resulting 403 names a project the user has no relationship with, giving no hint that the value came from ADC. This appears to be the same symptom reported in #291 ("403 permission error referencing unknown project ID (not user's project)", closed) but via a different trigger, so it may be worth a regression check there.
Environment
| Detail | Value |
|---|---|
| gws | 0.22.5 |
| OS | macOS (Darwin 25.5.0, arm64) |
| Auth | OAuth desktop-app flow, file keyring backend |
| gcloud ADC | present, with quota_project_id set to an unrelated project |
Steps to Reproduce
- Have gcloud ADC present with a quota project set — i.e.
~/.config/gcloud/application_default_credentials.jsoncontains"quota_project_id": "<unrelated-project-from-adc>". This is the normal state on any machine wheregcloud auth application-default loginhas been run. - Set up a gws binding in an isolated dir:
GOOGLE_WORKSPACE_CLI_CONFIG_DIR=/path/to/binding, with its ownclient_secret.json, and authenticate. - Remove the
project_idkey from/path/to/binding/client_secret.json(leaveclient_id/client_secretintact — OAuth itself does not needproject_id). - Make any raw Discovery call, e.g.:
GOOGLE_WORKSPACE_CLI_CONFIG_DIR=/path/to/binding \ gws gmail users messages get --params '{"userId":"me","id":"<MSG_ID>","format":"minimal"}'
Expected Behavior
With no project_id in the binding's client_secret.json, gws should either:
- omit
x-goog-user-projectentirely (which per #729 is arguably correct for Workspace APIs — quota attributes to the OAuth client automatically); or - fail loudly with a clear message that no quota project is configured for this binding
— but not silently adopt a project from machine-global gcloud state that lives outside the configured CONFIG_DIR.
Actual Behavior
The quota project silently becomes the ADC quota_project_id, and the call 403s against a project the binding never referenced:
{
"error": {
"code": 403,
"message": "Caller does not have required permission to use project <unrelated-project-from-adc>. Grant the caller the roles/serviceusage.serviceUsageConsumer role, or a custom role with the serviceusage.services.use permission, by visiting https://console.developers.google.com/iam-admin/iam?project=<unrelated-project-from-adc> and then retry.",
"reason": "forbidden"
}
}
Restoring project_id flips the named project back to the client's own, confirming the fallback chain is:
client_secret.json project_id → (if absent) ADC quota_project_id → (no "none" option)
Additional Context
Honest scoping — two caveats so this is prioritised correctly:
- The trigger is narrow. A
client_secret.jsondownloaded from the Cloud Console always includesproject_id; I reached this state by removing it deliberately, while probing whether the quota stamp of #729 could be suppressed. Users are most likely to hit it via a hand-edited or hand-assembled client file. - If #729 is fixed by not sending
x-goog-user-projectfor Workspace APIs, this fallback likely becomes moot. I'm filing it separately because the isolation escape is a defect in its own right — a binding scoped byCONFIG_DIRsilently consuming machine-global ADC state is surprising regardless of which project ends up in the header — and because it's a second data point that the quota-project resolution logic is doing more than it needs to.
Possibly related: #857 (GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE ignored when credentials.enc exists) looks like the same genre — ambient/co-located state overriding an explicitly configured binding.
- Lingua principale
- Rust
- Stelle
- 32.3k
- Fork
- 2k
- Merge medio
- 16h 3m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleworkspace/cli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
googleworkspace/cli#984 ·
I maintainer di solito rispondono entro 1 giorno
-
auth export masks secrets by default with no warning; consumers fail later with invalid_clientAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
googleworkspace/cli#983 ·
I maintainer di solito rispondono entro 1 giorno
-
Replace gemini with agyAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
googleworkspace/cli#958 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
googleworkspace/cli#921 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
googleworkspace/cli#920 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleworkspace/cli
Issue simili
-
area:cli area:security bug priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
rtk-ai/rtk#5127 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
status: new topic: ga4gh-sdk type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
comp-rbac
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ClickHouse/ClickHouse#131875 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesForse già presa @Borg93 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
lance-format/lance#11117 ·
I maintainer di solito rispondono entro 2 giorni