Skip to content

Adding aptos service implementation#340

Open
yashnevatia wants to merge 13 commits intodevelopfrom
aptos-service
Open

Adding aptos service implementation#340
yashnevatia wants to merge 13 commits intodevelopfrom
aptos-service

Conversation

@yashnevatia
Copy link

No description provided.

@yashnevatia yashnevatia requested a review from a team as a code owner February 16, 2026 16:47

balance, err := client.AccountAPTBalance(addr)
if err != nil {
s.logger.Warnw("failed to get balance for account, skipping", "account", account, "address", addr.String(), "error", err)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by an access to authKey
flows to a logging call.

Copilot Autofix

AI 2 days ago

In general, to fix clear-text logging of sensitive information, you either (a) omit the sensitive field from logs, or (b) obfuscate/redact it before logging so that it cannot be reversed to the original value. Here, the specific issue is that addr.String() (derived from an authKey) is logged in a warning message when fetching an account’s balance fails.

The safest, minimal-change fix is to stop logging the full address string and either remove it entirely or replace it with a redacted/hashed form. Since we already log "account", account (the original hex public key string) and "error", err, operational debugging remains possible even without the full address. To avoid introducing new helper functions or dependencies, the simplest approach is to remove "address", addr.String() from the Warnw call on line 237. No other code paths use this value in logs, so this single change eliminates the flagged flow without changing program behavior (the balance query itself still uses addr; only the log message changes).

Concretely:

  • In relayer/aptos_service.go, inside getAccountWithHighestBalance, edit the Warnw call in the if err != nil block around line 237.
  • Remove the "address", addr.String() key-value pair from the structured log fields.
  • No imports, methods, or additional definitions are required.

Suggested changeset 1
relayer/aptos_service.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/relayer/aptos_service.go b/relayer/aptos_service.go
--- a/relayer/aptos_service.go
+++ b/relayer/aptos_service.go
@@ -234,7 +234,7 @@
 
 		balance, err := client.AccountAPTBalance(addr)
 		if err != nil {
-			s.logger.Warnw("failed to get balance for account, skipping", "account", account, "address", addr.String(), "error", err)
+			s.logger.Warnw("failed to get balance for account, skipping", "account", account, "error", err)
 			continue
 		}
 
EOF
@@ -234,7 +234,7 @@

balance, err := client.AccountAPTBalance(addr)
if err != nil {
s.logger.Warnw("failed to get balance for account, skipping", "account", account, "address", addr.String(), "error", err)
s.logger.Warnw("failed to get balance for account, skipping", "account", account, "error", err)
continue
}

Copilot is powered by AI and may make mistakes. Always verify output.

select {
case a.broadcastChan <- transactionID:
ctxLogger.Debugw("Tx enqueued", "fromAddr", fromAddress)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by an access to authKey
flows to a logging call.

Copilot Autofix

AI 8 days ago

To fix the problem, we should ensure that the potentially sensitive value (fromAddress) is not logged in clear text. The simplest way to do this without changing functional behavior is to either (1) remove the "fromAddr" field from the log entirely, or (2) log only a non-sensitive, obfuscated form (e.g., a truncated address or a stable hash) that still supports debugging without exposing the full address.

The single best minimally invasive fix here is to remove or anonymize the logged address at the debug line in EnqueueCRE in relayer/txm/txm.go. Since the transaction ID is already part of the contextual logger (GetContexedTxLogger), and the tx object contains the FromAddress stored in memory for later use, logging the full fromAddress is not necessary. We can change:

ctxLogger.Debugw("Tx enqueued", "fromAddr", fromAddress)

either to:

ctxLogger.Debugw("Tx enqueued")

or to an obfuscated form like:

ctxLogger.Debugw("Tx enqueued", "fromAddr_suffix", fromAddress[len(fromAddress)-6:])

if you still want some address context. To stay conservative and avoid even partial leakage, the cleanest fix is to remove the address field entirely.

Concretely:

  • File: relayer/txm/txm.go
  • In EnqueueCRE, modify the Debugw call in the case a.broadcastChan <- transactionID: branch to stop including fromAddress.
  • No new imports or helpers are required for the “remove field” approach.

Suggested changeset 1
relayer/txm/txm.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/relayer/txm/txm.go b/relayer/txm/txm.go
--- a/relayer/txm/txm.go
+++ b/relayer/txm/txm.go
@@ -292,7 +292,7 @@
 
 	select {
 	case a.broadcastChan <- transactionID:
-		ctxLogger.Debugw("Tx enqueued", "fromAddr", fromAddress)
+		ctxLogger.Debugw("Tx enqueued")
 	default:
 		// if the channel is full, we drop the transaction.
 		// we do this instead of setting the tx in `a.transactions` post-broadcast to avoid a race
EOF
@@ -292,7 +292,7 @@

select {
case a.broadcastChan <- transactionID:
ctxLogger.Debugw("Tx enqueued", "fromAddr", fromAddress)
ctxLogger.Debugw("Tx enqueued")
default:
// if the channel is full, we drop the transaction.
// we do this instead of setting the tx in `a.transactions` post-broadcast to avoid a race
Copilot is powered by AI and may make mistakes. Always verify output.
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.

1 participant