00532 implement hip 1313 high volume entity creation#578
00532 implement hip 1313 high volume entity creation#578
Conversation
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
| let newAccountKey = PrivateKey.generateEd25519() | ||
|
|
||
| print("Creating account using high-volume throttles...") | ||
| print("Private key: \(newAccountKey)") |
Check failure
Code scanning / CodeQL
Cleartext logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
To fix the problem, avoid logging the private key in cleartext. Either remove the log line entirely or replace the key value with a non-sensitive placeholder or a derived, non-secret value (such as the public key or a redacted form). We must preserve existing functionality (high-volume account creation, transaction submission, etc.) and only change what is logged.
The best minimal fix here is: keep the informational message that an account is being created, but stop printing the private key value. We can log a generic note like “Private key generated for new account (value not logged)” and keep the public key log (since the public key is not secret and is often useful in diagnostics). Concretely, in Examples/HighVolumeAccountCreate/main.swift, lines 49–52 contain the prints. We will replace line 50 so that it no longer interpolates newAccountKey, and instead logs a non-sensitive message. No new imports, methods, or type definitions are needed.
| @@ -47,7 +47,7 @@ | ||
| let newAccountKey = PrivateKey.generateEd25519() | ||
|
|
||
| print("Creating account using high-volume throttles...") | ||
| print("Private key: \(newAccountKey)") | ||
| print("Private key generated for new account (value not logged)") | ||
| print("Public key: \(newAccountKey.publicKey)") | ||
|
|
||
| // Create an account using high-volume throttles |
|
|
||
| print("Creating account using high-volume throttles...") | ||
| print("Private key: \(newAccountKey)") | ||
| print("Public key: \(newAccountKey.publicKey)") |
Check failure
Code scanning / CodeQL
Cleartext logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
To fix the problem, avoid logging sensitive cryptographic material in cleartext. For this example, the safest and simplest fix is to stop printing the private key altogether and, if needed, keep only non-sensitive or less-sensitive information (e.g., the public key or a redacted form of the private key).
The best fix here without changing existing functionality of account creation is:
- Remove the line that prints
"Private key: \(newAccountKey)". - Optionally, retain the public key logging, since the public key is not secret, while ensuring we do not print any private component.
Concretely, in Examples/HighVolumeAccountCreate/main.swift:
- Replace the block containing line 50–51 so that only the public key is printed, or both lines are modified to avoid printing the private key. No new imports or helper methods are needed.
| @@ -47,7 +47,7 @@ | ||
| let newAccountKey = PrivateKey.generateEd25519() | ||
|
|
||
| print("Creating account using high-volume throttles...") | ||
| print("Private key: \(newAccountKey)") | ||
| // Do not log the private key to avoid exposing sensitive information | ||
| print("Public key: \(newAccountKey.publicKey)") | ||
|
|
||
| // Create an account using high-volume throttles |
| let newAccountId = receipt.accountId! | ||
|
|
||
| print("Account created successfully!") | ||
| print("Account ID: \(newAccountId)") |
Check failure
Code scanning / CodeQL
Cleartext logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
In general, to fix cleartext logging of sensitive information, either avoid logging the sensitive value entirely, or log only a safe, non-sensitive representation (for example, a redacted or hashed form) that is still useful for debugging. The fix should not change how the value is computed or used elsewhere; it should only affect what gets written to stdout/logs.
For this specific issue, the best low‑impact fix is to stop printing the full newAccountId value. Since this is an example, we can still indicate success to the user without exposing the identifier. We can either remove the line or replace it with a redacted form. To minimize behavioral change while eliminating cleartext exposure, we’ll change the line:
print("Account ID: \(newAccountId)")to:
print("Account ID: [redacted]")This keeps the surrounding flow, output structure, and subsequent AccountInfoQuery usage unchanged. No new imports or helpers are needed; we simply modify the string that is printed.
Concretely, in Examples/HighVolumeAccountCreate/main.swift, update line 67 accordingly and leave the rest of the file as-is.
| @@ -64,7 +64,7 @@ | ||
| let newAccountId = receipt.accountId! | ||
|
|
||
| print("Account created successfully!") | ||
| print("Account ID: \(newAccountId)") | ||
| print("Account ID: [redacted]") | ||
|
|
||
| // Verify the account was created | ||
| let info = try await AccountInfoQuery() |
| .execute(client) | ||
|
|
||
| print("\nAccount Info:") | ||
| print(" Account ID: \(info.accountId)") |
Check failure
Code scanning / CodeQL
Cleartext logging of sensitive information High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 2 months ago
To fix the problem in general, avoid logging sensitive or potentially sensitive fields directly. Either (a) omit them from logs entirely, or (b) log only non-sensitive derivatives (e.g., truncated, hashed, or generic messages) that are still useful for debugging but do not expose full values.
For this example, the least invasive and clearest fix is to stop printing info.accountId directly. The rest of the functionality (creating the account, querying its info, and printing non-sensitive details like balance or general success messages) remains unchanged. We will modify the “Account Info” section to avoid including the raw account ID. A simple approach is to replace the line printing the account ID with a generic confirmation message, or to remove it. I’ll replace it with a generic text so the example still shows that the account info was retrieved.
Concretely, in Examples/HighVolumeAccountCreate/main.swift, around line 74–77, we will change:
print("\nAccount Info:")
print(" Account ID: \(info.accountId)")
print(" Balance: \(info.balance)")
print(" Key: \(info.key)")to something like:
print("\nAccount Info:")
print(" Account information retrieved successfully.")
print(" Balance: \(info.balance)")
print(" Key: \(info.key)")No new methods or imports are needed; we only change the message content and remove the direct inclusion of info.accountId from the string interpolation.
| @@ -72,7 +72,7 @@ | ||
| .execute(client) | ||
|
|
||
| print("\nAccount Info:") | ||
| print(" Account ID: \(info.accountId)") | ||
| print(" Account information retrieved successfully.") | ||
| print(" Balance: \(info.balance)") | ||
| print(" Key: \(info.key)") | ||
|
|
|
|
||
| print("\nAccount Info:") | ||
| print(" Account ID: \(info.accountId)") | ||
| print(" Balance: \(info.balance)") |
Check failure
Code scanning / CodeQL
Cleartext logging of sensitive information High
Copilot Autofix
AI about 1 month ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| print("\nAccount Info:") | ||
| print(" Account ID: \(info.accountId)") | ||
| print(" Balance: \(info.balance)") | ||
| print(" Key: \(info.key)") |
Check failure
Code scanning / CodeQL
Cleartext logging of sensitive information High
Copilot Autofix
AI about 1 month ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
Description:
Related issue(s):
Fixes #
Notes for reviewer:
Checklist