Skip to content

Commit

Permalink
Update descriptions and add example
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-andrivet-sonarsource committed Sep 19, 2023
1 parent 2dbf03f commit 8d12881
Showing 1 changed file with 52 additions and 17 deletions.
69 changes: 52 additions & 17 deletions rules/S6777/secrets/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Shippo is a multi-carrier shipping platform that helps businesses streamline their shipping processes. It provides a unified API and dashboard that allows businesses to connect with multiple shipping carriers. Shippo API tokens are used for authentication and authorization purposes when making API requests.

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

== Why is this an issue?
Expand All @@ -6,30 +8,28 @@ include::../../../shared_content/secrets/rationale.adoc[]

=== What is the potential impact?

The consequences vary greatly depending on the situation and the secret-exposed
audience. Still, two main scenarios should be considered.
If a Shippo API token is leaked, it can have several consequences:

include::../../../shared_content/secrets/impact/banking_financial_loss.adoc[]
==== Unauthorized Access

include::../../../shared_content/secrets/impact/blockchain_data_exposure.adoc[]
The leaked API token can be used by unauthorized individuals to gain access to your Shippo account and shipping data. This can lead to potential misuse of your account, such as generating shipping labels, accessing sensitive information, or making unauthorized changes to your shipping settings.

include::../../../shared_content/secrets/impact/codeless_vulnerability_chaining.adoc[]
==== Data Breach

include::../../../shared_content/secrets/impact/data_compromise.adoc[]
If the leaked API token is associated with a user account that has access to sensitive customer or business data, it can result in a data breach. This can lead to the exposure of personal information, shipping addresses, payment details, or other confidential data, potentially causing harm to your customers and your business reputation.

include::../../../shared_content/secrets/impact/financial_loss.adoc[]
==== Financial Loss

include::../../../shared_content/secrets/impact/malware_distribution.adoc[]
If the leaked API token is used to generate shipping labels or make shipping-related transactions, it can result in financial loss. Unauthorized individuals may exploit the token to generate fraudulent labels or make unauthorized shipments, leading to additional shipping costs or potential chargebacks.

include::../../../shared_content/secrets/impact/non_repudiation.adoc[]
==== Service Disruption

include::../../../shared_content/secrets/impact/personal_data_compromise.adoc[]
In some cases, if the leaked API token is used maliciously, it can cause service disruptions or performance issues. For example, an attacker may overload the Shippo API with excessive requests, leading to service unavailability or degraded performance for legitimate users.

include::../../../shared_content/secrets/impact/phishing.adoc[]
==== Reputation damage

include::../../../shared_content/secrets/impact/security_downgrade.adoc[]
If a token is leaked and used for malicious purposes, it can damage the reputation of the API provider. Users may lose trust in the security of the API, leading to a loss of business and credibility.

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

== How to fix it

Expand All @@ -41,11 +41,46 @@ include::../../../shared_content/secrets/fix/vault.adoc[]

=== Code examples

:example_secret: ghp_xd8KRQmqM8eGCdegBLeO5AJ4oS0VN3yWXWcw
:example_name: client_secret
:example_env: CLIENT_SECRET
==== Noncompliant code example

[source,java,diff-id=1,diff-type=noncompliant]
----
Shippo.setApiKey('shippo_live_258d9b4c41a8cb88ca7fb4b12c65083f658435ac'); // Noncompliant
HashMap<String, Object> addressMap = new HashMap<String, Object>();
addressMap.put("name", "Mr. Hippo");
addressMap.put("company", "Shippo");
addressMap.put("street1", "215 Clayton St.");
addressMap.put("city", "San Francisco");
addressMap.put("state", "CA");
addressMap.put("zip", "94117");
addressMap.put("country", "US");
addressMap.put("phone", "+1 555 341 9393");
addressMap.put("email", "[email protected]");
Address createAddress = Address.create(addressMap);
----

==== Compliant solution

[source,java,diff-id=1,diff-type=compliant]
----
Shippo.setApiKey(System.getenv("SHIPPO_API_TOKEN"));
HashMap<String, Object> addressMap = new HashMap<String, Object>();
addressMap.put("name", "Mr. Hippo");
addressMap.put("company", "Shippo");
addressMap.put("street1", "215 Clayton St.");
addressMap.put("city", "San Francisco");
addressMap.put("state", "CA");
addressMap.put("zip", "94117");
addressMap.put("country", "US");
addressMap.put("phone", "+1 555 341 9393");
addressMap.put("email", "[email protected]");
Address createAddress = Address.create(addressMap);
----

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

//=== How does this work?

Expand Down

0 comments on commit 8d12881

Please sign in to comment.