Are there any security concerns with sharing the client secrets of a Google API project?
Asked Answered
C

3

10

I'm working on a project using the YouTube Data API. The Python script I'm running uses a client secrets JSON file, which I presume is for verifying the account owner.

If I am having issues with it and need assistance, are there any security concerns with sharing this publicly? Is it even alright if it's held privately in a private github repository?

Corticosterone answered 11/6, 2020 at 1:11 Comment(1)
Googles TOS says that you may not give it out you agreed to this when you created your account developers.google.com/terms#d_user_privacy_and_api_clientsBrachiopod
B
11

If you check the Google Developer TOS which you agreed to when you created your account on Google developer console

enter image description here

It is against the TOS for you to share this file with anyone. This is secret and only intended for the developer or team of developers who created it. This pertains to the entire client secret json file you download from Google developer console or google cloud console.

Again DO not share your google secret file. No matter what the accepted answer stays about how problematic it may or may not, nor does it matter what type of client it is. Sharing the client secret file would be volatilizing the TOS you agreed to.

My corrections for another answer on this thread here

The answer in question has some statements that i strongly disagree with and feel may cause confusion to developers. Let me start by saying I am not an employee of Google, my comments are my own and from my experience with working googles oauth / identity server server for eight+ years and contact with google identity team. I am concerned that some of the information in the answer above may confuse some developers. Rather than just saying dont share them the other question tries incorrectly IMO to explain why it wouldn't be so bad to share them. I will explain why you should never share them beyond the fact that its against googles TOS.

The security implications depend on the type of client secret. You can tell the difference by whether the key in the JSON file is installed or web.

The type of client has no effect upon I how great the security risk would be. If we ignore the definition of what a constitutes a security risk completely and just say that any chance anyone could get access to a users account or authenticate a user on behalf of the project, would constitute to big of a security risk then there is no difference.

Using the following command I could authenticate myself all i need is the credentials file for your project

https://accounts.google.com/o/oauth2/auth?client_id={clientid}.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/analytics.readonly&response_type=code

This would only work 100% of the time for an installed application. Why is this bad if i am just authenticating my own user. I could then use my evil powers to send so many requests against the API that the target google developer project would be locked down by Google for spamming.

If i have stolen another users login and password i can login to them from your Google developer project and i have access to their data and Google thinks its you hacking them.

This is a little harder with a web application due to the Redirect URI, However a lot of developers include add localhost as a redirect uri when in development and forget to take it out (Please never leave localhost as a redirect uri when you are in proudcution) . So in the event you have left redirect URI as a valid redirect URI in a web browser client then I can do the exact same thing.

Remember I am now able to authenticate users based upon your project to access mostly my own data. However if you have also set up access to client data for example via google drive I may be able to access that as well. (Note: Im not Sure on this one i havent actually tried.)

If i have manged though man in the middle attack or some other means to get a users refresh token, and I have the client secret file I can now access users data because I can create new access tokens with my refresh token for as long as i want. This is probably a bit harder to achieve.

Web application secrets If the client secret is of the web type, then yes: you should absolutely not post it, and invalidate it if it gets exposed. This would allow a malicious entity to impersonate your backend and perform actions on your users' accounts on your behalf.

As stated above this will only be the case if the developer in question has left the redirect uri open for localhost or the person who now has your client secret file also has access to your web server. One very important fact is that if you have left localhost open i can then put up my own website using your credentials and set it up so it look exactly like your website. Users then think they are logging into Your super awesome app when in fact they are logging into Hacker Super awesome app giving them access to the users data. Again google thinks its you hacking them.

Installed application secrets If the client secret is an installed-type secret, then it's less problematic to share privately, as it doesn't grant the sorts of abilities a web application secret does, such as the ability to authenticate as users who grant your application permission to access their data. As the documentation notes, "in this context, the client secret is obviously not treated as a secret."

This is completely false Installed applications give the exact same permissions as web applications there is no difference with-regard to Oauth2 access an access token is an access token no matter if it was created for an installed application or a web application.

As stated above security risk with giving out access to your installed application this is actually worse. As there are no redirect uris with installed applications. Anyone that has access to your client secret file could authenticate users who assume they are you because they are being shown your consent screen. Not only is your Google developer project being hjacked but your reputation to your users who think that they are authenticating to Super awesome app and in fact they are not granting the person who has stolen your credentials access to their data.

I would like to add one last thing. If you give another person your project credentials. The client secret json file. You are giving them access to make calls on your behalf. If you have bulling set up lets say against google maps api. You will be charged for the calls they make.

I hope this helps to clear up some of the confusion related to the accepted anwser.

Brachiopod answered 11/6, 2020 at 7:48 Comment(3)
Are you suggesting that "in this context, the client secret is obviously not treated as a secret." is false? That's straight out of the documentation. It's completely impossible to ship an installed app with a client secret without a determined user being able to extract it - they have the binary, with the secret embedded in it. "If i have stolen another users login and password" then you can impersonate the user and log into whatever app you want, without needing to know the client secret.Camouflage
Actually i have spoken with the Google Oath team on this subject a number of times as i have shipped several applications that contain connections to google. Its a gray area your not supposed to share it and shipping it in a binary would be aginst that. I was able to do it by not shipping the client secret's in the binary. Access was grated though a connection to my server. I have been working with Googles Oauth servers for eight years. Want something else to consider. Have you thought about Client sided client secret json file. How do you keep that secret?Brachiopod
Alright, I'll make sure to not share the secrets file and private the github repo with itCorticosterone
A
2

Yes, this is a problem. It's called a "client secret" for a reason. If it does become exposed, you should take steps to invalidate it and get a new one so that someone doesn't try to impersonate you.

Appellative answered 11/6, 2020 at 1:53 Comment(0)
C
2

Short answer: the security implications depend on the type of secret, but you should not share it publicly for other reasons, including the Terms of Service, which state that:

You will keep your credentials confidential and make reasonable efforts to prevent and discourage other API Clients from using your credentials. Developer credentials may not be embedded in open source projects.

The security implications depend on the type of client secret. You can tell the difference by whether the key in the JSON file is installed or web.

Web application secrets

If the client secret is of the web type, then yes: you should absolutely not post it, and invalidate it if it gets exposed. This would allow a malicious entity to impersonate your backend and perform actions on your users' accounts on your behalf.

Installed application secrets

If the client secret is an installed-type secret, then it's less problematic to share privately, as it doesn't grant the sorts of abilities a web application secret does, such as the ability to authenticate as users who grant your application permission to access their data. As the documentation notes, "in this context, the client secret is obviously not treated as a secret."

You still should not post it publicly on GitHub, a Stack Overflow question, or other public places, as posting it publicly increases the probability of someone copying your code in its entirety or otherwise using your client secret in their own project, which might cause problems and likely would run afoul of the Terms of Service. People trying to reproduce your issue could pretty easily generate credentials to drop into your code—credentials are a reasonable thing to leave out of a question.

Camouflage answered 11/6, 2020 at 2:38 Comment(9)
Unless you work for Google you can not claim to understand googles security rules. Seeing as you did not originally know that it was against googles TOS. Thank you for updating your answer. However I am still worried about your statement specifically your opinion of what is problematic Any attitude you may detect is concern for the developer community and false informationBrachiopod
It depends on the type of client secret. <-- false.Brachiopod
@RyanM - do you have a reference for "[installed application secretes] doesn't grant the sorts of abilities a web application secret does"?Mylor
@Mylor Take a look at developers.google.com/adwords/api/docs/guides/… - many of the details are specific to the AdWords API, but it gives the general idea.Camouflage
@DaImTo I'm glad for your concern for our developers, and appreciate you bringing something I was not aware of to my attention so that I could ensure that my answer does not lead someone down the wrong path. I have further clarified my answer, and that sentence specifically, to emphasize that most of it is solely a discussion of the security implications, and that, as you correctly state, these secrets should not be posted in public source code.Camouflage
@RyanM i have edited my answer to add detailed information to clear up the miss understandings in your answer. You might want to read the part on major security risks with Installed applications. Which your answer still stats are "less problematic"Brachiopod
@RyanM - I haven't used AdWords, admitedly, but that page makes it sound like installed keys are less secure since they have the same power under one master account. Plus I see this quote "The main difference [between the two secret types] is whether or not you require a callback to your website after issuing the token."Mylor
@Mylor I've admittedly not used server (web) client secrets myself, but note that the documentation for the entire API says that for installed apps, "the client secret is obviously not treated as a secret". This is because the secret is necessarily embedded in the client software installed on the user's device. I believe the doc you're referring to is saying that once you're logged into the application, it would also have an access token and a refresh token for your account, giving it powers that just the secret doesn'tCamouflage
So how to deploy a web service (backend) with access to this secret JSON file if it shouldnt be committed in to source control?Counterpoise

© 2022 - 2024 — McMap. All rights reserved.