Skip to content

Possible private Key detected in start.sh #8

Description

@begininvoke

Came across something in start.sh around line 95 that looked worth flagging.

This script hard‑codes an EC private key. Embedding private keys in source code exposes cryptographic material to anyone with repository access, enabling attackers to impersonate the service, decrypt data, or sign malicious transactions. The issue maps to CWE‑798 (Use of Hard‑coded Credentials) and is classified as High severity because the key provides full cryptographic authority and is stored in clear‑text within version‑controlled files.

The code in question
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIM4792SEtPqIt1ywqTd/0bYidBqpYV/+siNnfBYsdUYsAoGCCqGSM49

Something like this might fix it:

diff --git a/start.sh b/start.sh
--- a/start.sh
+++ b/start.sh
@@
------BEGIN EC PRIVATE KEY-----
-MHcCAQEEIM4792SEtPqIt1ywqTd/0bYidBqpYV/+siNnfBYsdUYsAoGCCqGSM49
-... (rest of key) ...
------END EC PRIVATE KEY-----
+# Load the EC private key from a protected file instead of hard‑coding it.
+PRIVATE_KEY_PATH="${HOME}/.keys/ec_private_key.pem"
+if [[ -f "$PRIVATE_KEY_PATH" ]]; then
+    PRIVATE_KEY=$(cat "$PRIVATE_KEY_PATH")
+else
+    echo "Error: Private key not found at $PRIVATE_KEY_PATH" >&2
+    exit 1
+fi

For reference: rule generic.secrets.security.detected-private-key.detected-private-key, CWE-798 (Use of Hard-coded Credentials). Rated high.

The suggested change is untested against this project, so please read it before applying it.


Found with automated scanning (RedGem) and reviewed before opening. If it is not useful, closing it is completely fine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions