Skip to content

Commit a678e92

Browse files
authored
fix(auth): remove hardcoded OAuth client secret from published npm package (CWE-798) (#1139)
- Removed DEFAULT_CLASP_OAUTH_CLIENT_SECRET completely from the codebase - Default login now runs as a public client (client ID only) - Explicitly added build/ to .npmignore - Preserved full backward compatibility for --creds and V1 .clasprc.json files Closes the vulnerability reported via Google OSS VRP. Co-authored-by: g0w6y <g0w6y@users.noreply.github.com>
1 parent 1a1665e commit a678e92

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
src
22
test
33
.*
4+
build

src/auth/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {AuthorizationCodeFlow} from './auth_code_flow.js';
2525
import {CredentialStore} from './credential_store.js';
2626
import {FileCredentialStore} from './file_credential_store.js';
2727
import {LocalServerAuthorizationCodeFlow} from './localhost_auth_code_flow.js';
28-
import {DEFAULT_CLASP_OAUTH_CLIENT_ID, DEFAULT_CLASP_OAUTH_CLIENT_SECRET} from './oauth_client.js';
28+
import {DEFAULT_CLASP_OAUTH_CLIENT_ID} from './oauth_client.js';
2929
import {ServerlessAuthorizationCodeFlow} from './serverless_auth_code_flow.js';
3030

3131
const debug = Debug('clasp:auth');
@@ -268,7 +268,6 @@ function createDefaultOAuthClient() {
268268
// Default client
269269
const client = new OAuth2Client({
270270
clientId: DEFAULT_CLASP_OAUTH_CLIENT_ID,
271-
clientSecret: DEFAULT_CLASP_OAUTH_CLIENT_SECRET,
272271
redirectUri: 'http://localhost',
273272
});
274273
debug('Created built-in oauth client, id: %s', client._clientId);

src/auth/file_credential_store.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import fs from 'fs';
2020
import {CredentialStore, StoredCredential} from './credential_store.js';
21-
import {DEFAULT_CLASP_OAUTH_CLIENT_ID, DEFAULT_CLASP_OAUTH_CLIENT_SECRET} from './oauth_client.js';
21+
import {DEFAULT_CLASP_OAUTH_CLIENT_ID} from './oauth_client.js';
2222

2323
// Initial .clasprc.json format, single credential per file
2424
type V1LocalFileFormat = {
@@ -165,7 +165,6 @@ export class FileCredentialStore implements CredentialStore {
165165
expiry_date: store.exprity_date,
166166
token_type: store.token_type,
167167
client_id: DEFAULT_CLASP_OAUTH_CLIENT_ID,
168-
client_secret: DEFAULT_CLASP_OAUTH_CLIENT_SECRET,
169168
};
170169
}
171170
return null;

src/auth/oauth_client.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
// Copyright 2025 Google LLC
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// https://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1416

1517
// Shared constants and helpers for identifying clasp OAuth clients.
18+
//
19+
// NOTE: The hardcoded client secret has been removed for security reasons.
20+
// Default login now runs as a public client (client ID only, no secret).
21+
// This eliminates the sensitive data exposure in the published npm tarball.
1622

1723
export const DEFAULT_CLASP_OAUTH_CLIENT_ID =
1824
'1072944905499-vm2v2i5dvn0a0d2o4ca36i1vge8cvbn0.apps.googleusercontent.com';
19-
export const DEFAULT_CLASP_OAUTH_CLIENT_SECRET = 'v6V3fKV_zWU7iw1DrpO1rknX';
2025

2126
export type OAuthClientType = 'google-provided' | 'user-provided';
2227

0 commit comments

Comments
 (0)