Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create rule S7144: Bitbucket keys should not be disclosed (APPSEC-1864) #4476

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rules/S7144/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
56 changes: 56 additions & 0 deletions rules/S7144/secrets/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"title": "BitBucket OAuth credentials should not be disclosed",
"type": "VULNERABILITY",
"code": {
"impacts": {
"SECURITY": "HIGH"
},
"attribute": "TRUSTWORTHY"
},
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "30min"
},
"tags": [
"cwe",
"cert"
],
"defaultSeverity": "Blocker",
"ruleSpecification": "RSPEC-7144",
"sqKey": "S7144",
"scope": "All",
"securityStandards": {
"CWE": [
798,
259
],
"OWASP": [
"A3"
],
"CERT": [
"MSC03-J."
],
"OWASP Top 10 2021": [
"A7"
],
"PCI DSS 3.2": [
"6.5.10"
],
"PCI DSS 4.0": [
"6.2.4"
],
"ASVS 4.0": [
"2.10.4",
"3.5.2",
"6.4.1"
],
"STIG ASD_V5R3": [
"V-222642"
]
},
"defaultQualityProfiles": [
"Sonar way"
],
"quickfix": "unknown"
}
65 changes: 65 additions & 0 deletions rules/S7144/secrets/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

include::../../../shared_content/secrets/description.adoc[]

== Why is this an issue?

include::../../../shared_content/secrets/rationale.adoc[]

If attackers gain access to a BitBucket OAuth credentials, they will be able to interact with BitBucket API on behalf of the compromised account.

=== What is the potential impact?

Bitbucket keys allow external services to access resources on a user’s behalf with the OAuth 2.0 protocol.
They are used to authenticate applications, services, or APIs using BitBucket for login and access-control.

Below are some real-world scenarios that illustrate some impacts of an attacker
exploiting the secret.

include::../../../shared_content/secrets/impact/source_code_compromise.adoc[]

include::../../../shared_content/secrets/impact/supply_chain_attack.adoc[]

== How to fix it

include::../../../shared_content/secrets/fix/revoke.adoc[]

include::../../../shared_content/secrets/fix/recent_use.adoc[]

include::../../../shared_content/secrets/fix/vault.adoc[]

=== Code examples

:example_secret: MP76PZGLQmw63rxZYJ
:example_name: bitbucket-key
:example_env: BITBUCKET_KEY
sebastien-andrivet-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
sebastien-andrivet-sonarsource marked this conversation as resolved.
Show resolved Hide resolved

==== Noncompliant code example

[source,java,diff-id=1,diff-type=noncompliant,subs="attributes"]
----
props.set("bitbucket.oauth-key", "MP76PZGLQmw63rxZYJ") // Noncompliant
props.set("bitbucket.oauth-secret", "ASgzPac3EPbXHbTSw6DyUagJZ8ThnUFG") // Noncompliant
----

==== Compliant solution

[source,java,diff-id=1,diff-type=compliant,subs="attributes"]
----
props.set("bitbucket.oauth-key", System.getenv("BITBUCKET_OAUTH_KEY")
props.set("bitbucket.oauth-secret", System.getenv("BITBUCKET_OAUTH_SECRET")
----


//=== How does this work?

//=== Pitfalls

//=== Going the extra mile

== Resources

sebastien-andrivet-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
* Bitbucket Support - https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/[Use OAuth on Bitbucket Cloud]

include::../../../shared_content/secrets/resources/standards.adoc[]

//=== Benchmarks
Loading