Skip to content

Fix GCP Service Agent Token Theft vulnerability in connection testing - #1623

Closed
akkaur wants to merge 1 commit into
developfrom
fix-vrp-service-agent-token-theft
Closed

akkaur wants to merge 1 commit into
developfrom
fix-vrp-service-agent-token-theft

Conversation

@akkaur

@akkaur akkaur commented Sep 2, 2026 •

Copy link
Copy Markdown

This PR updates GCPUtils.loadServiceAccountCredentials to emit a WARN audit log whenever the credentials supplied (via file path or JSON) are not of the standard service_account type (e.g., external_account, authorized_user, impersonated_service_account).

There is no change to existing credential parsing behavior.

@akkaur
akkaur requested a review from sahusanket September 2, 2026 18:16
@akkaur
akkaur marked this pull request as ready for review September 2, 2026 18:17
@akkaur akkaur self-assigned this Sep 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates GCPUtils.loadServiceAccountCredentials to load credentials using ServiceAccountCredentials.fromStream instead of GoogleCredentials.fromStream and adds corresponding unit tests. The feedback suggests enhancing the positive test case by asserting that the returned credentials are an instance of ServiceAccountCredentials to ensure the security fix is explicitly verified.

Comment thread src/test/java/io/cdap/plugin/gcp/common/GCPUtilsTest.java Outdated
@akkaur
akkaur force-pushed the fix-vrp-service-agent-token-theft branch 3 times, most recently from 04bc968 to 354a90a Compare September 2, 2026 18:26
@akkaur

akkaur commented Sep 2, 2026

Copy link
Copy Markdown
Author

/gemini review

1 similar comment
@akkaur

akkaur commented Sep 2, 2026

Copy link
Copy Markdown
Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the loadServiceAccountCredentials method in GCPUtils to return ServiceAccountCredentials instead of GoogleCredentials, preventing the loading of non-service-account credentials. A new test class GCPUtilsTest has been added to validate this behavior with both positive and negative test cases. I have no feedback to provide.

@gemini-code-assist

Copy link
Copy Markdown

The changes in this pull request correctly address the identified security vulnerability by restricting credential parsing to ServiceAccountCredentials. This prevents the use of malicious external_account payloads that could lead to token exfiltration. The addition of GCPUtilsTest.java provides essential regression testing to ensure this restriction remains in place. The implementation is robust and follows security best practices for GCP credential handling.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates GCPUtils to load credentials specifically as ServiceAccountCredentials instead of the generic GoogleCredentials to mitigate potential external account payload attacks, and introduces unit tests to verify this behavior. The review feedback suggests programmatically generating a dummy RSA keypair at runtime in the test instead of hardcoding a static private key string, which prevents triggering automated credential scanners in CI/CD pipelines.

Comment thread src/test/java/io/cdap/plugin/gcp/common/GCPUtilsTest.java Outdated
@akkaur
akkaur force-pushed the fix-vrp-service-agent-token-theft branch from 354a90a to e1c02fe Compare September 2, 2026 18:42
@akkaur

akkaur commented Sep 2, 2026

Copy link
Copy Markdown
Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates GCPUtils.loadServiceAccountCredentials to load credentials using ServiceAccountCredentials.fromStream instead of the generic GoogleCredentials.fromStream to prevent loading arbitrary external account credentials. Additionally, a new test class GCPUtilsTest has been added to verify both positive and negative scenarios for loading service account credentials. No review comments were provided, so there is no feedback to address.

Comment thread src/main/java/io/cdap/plugin/gcp/common/GCPUtils.java Outdated
Emit a WARN audit log in GCPUtils.loadServiceAccountCredentials whenever the
credentials supplied via the service account file path / JSON are not of type
'service_account' (e.g. external_account, authorized_user), so that any such
usage can be identified. No behaviour change.
@akkaur
akkaur force-pushed the fix-vrp-service-agent-token-theft branch 3 times, most recently from ab79f09 to dc17146 Compare October 5, 2026 11:48
@akkaur
akkaur requested a review from vsethi09 October 5, 2026 15:15
@akkaur akkaur closed this Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants