Skip to content

Adding aptos service implementation#340

Draft
yashnevatia wants to merge 19 commits intodevelopfrom
aptos-service
Draft

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

Conversation

@yashnevatia
Copy link

@yashnevatia yashnevatia commented Feb 16, 2026

@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 about 3 hours 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.

@yashnevatia yashnevatia marked this pull request as draft March 5, 2026 18:51
@yashnevatia yashnevatia requested a review from Fletch153 March 6, 2026 10:09

acc := utils.Ed25519PublicKeyToAddress(ed25519PublicKey)
fromAddress := acc.String()
a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", 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 about 4 hours ago

To fix the issue, avoid logging the full fromAddress value derived from authKey, or log only a non-sensitive, obfuscated version. This preserves functionality while preventing clear-text storage of potentially sensitive account identifiers.

The best low-impact fix is to change the log statement at line 281 in relayer/txm/txm.go to either (a) omit the address value entirely, or (b) log only a truncated/masked version (for example, first/last few characters) that is sufficient for debugging but useless for an attacker. No other logic relies on this log output, so we do not need to change any control flow or data structures.

Concretely, in relayer/txm/txm.go:

  • Replace the existing Infow call that logs "fromAddress", fromAddress with a version that either:
    • does not include the "fromAddress" key at all, or
    • logs an obfuscated string constructed from fromAddress, such as a prefix and suffix plus a length.
  • This can be done inline without new imports. For example:
    • maskedFromAddress := fromAddress[:6] + "..." + fromAddress[len(fromAddress)-4:]
    • Then log "fromAddress", maskedFromAddress.
  • Ensure we only modify the logging, leaving subsequent parsing of fromAddress and transaction creation unchanged.

No new methods or external libraries are required; this is a simple string manipulation in the existing file.

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
@@ -278,7 +278,11 @@
 
 	acc := utils.Ed25519PublicKeyToAddress(ed25519PublicKey)
 	fromAddress := acc.String()
-	a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", fromAddress)
+	maskedFromAddress := fromAddress
+	if len(fromAddress) > 10 {
+		maskedFromAddress = fromAddress[:6] + "..." + fromAddress[len(fromAddress)-4:]
+	}
+	a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", maskedFromAddress)
 
 	fromAccountAddress := &aptos.AccountAddress{}
 	err = fromAccountAddress.ParseStringRelaxed(fromAddress)
EOF
@@ -278,7 +278,11 @@

acc := utils.Ed25519PublicKeyToAddress(ed25519PublicKey)
fromAddress := acc.String()
a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", fromAddress)
maskedFromAddress := fromAddress
if len(fromAddress) > 10 {
maskedFromAddress = fromAddress[:6] + "..." + fromAddress[len(fromAddress)-4:]
}
a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", maskedFromAddress)

fromAccountAddress := &aptos.AccountAddress{}
err = fromAccountAddress.ParseStringRelaxed(fromAddress)
Copilot is powered by AI and may make mistakes. Always verify output.
fromAccountAddress := &aptos.AccountAddress{}
err = fromAccountAddress.ParseStringRelaxed(fromAddress)
if err != nil {
a.baseLogger.Errorw("TestingAptosWriteCap: EnqueueCRE - failed to parse from address", "fromAddress", fromAddress, "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 about 4 hours ago

To fix the issue, we should avoid logging the full fromAddress value directly. Instead, we can either (a) omit it entirely from logs, or (b) log only a redacted form (for example, the first and last few characters), which is enough for debugging while not exposing the complete derived auth key. This addresses the CodeQL concern about clear-text logging of sensitive data without changing any functional behavior of the transaction processing.

The most targeted, non-invasive fix is:

  • Keep computing fromAddress as before and using it for parsing and transaction construction.
  • Change the two log statements that include "fromAddress", fromAddress to instead include a redacted value, e.g. RedactAddress(fromAddress).
  • Implement a small helper RedactAddress in relayer/utils/address.go that takes an address string and returns a redacted representation (e.g. 0x1234...abcd), falling back sensibly for short strings. This keeps logic centralized and reusable.
  • Use only standard library functionality in the helper to avoid extra dependencies.

Concretely:

  • In relayer/utils/address.go, add a new helper function RedactAddress(addr string) string after the existing functions.
  • In relayer/txm/txm.go, update:
    • The info log at line 281 to log "fromAddress", utils.RedactAddress(fromAddress) instead of the full address.
    • The error log at line 286 similarly to log the redacted address instead of the full one.

No changes are required to imports beyond using the already imported github.com/smartcontractkit/chainlink-aptos/relayer/utils in txm.go. The new helper in address.go uses only len and string slicing, so no new imports are necessary there.

Suggested changeset 2
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
@@ -278,12 +278,12 @@
 
 	acc := utils.Ed25519PublicKeyToAddress(ed25519PublicKey)
 	fromAddress := acc.String()
-	a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", fromAddress)
+	a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", utils.RedactAddress(fromAddress))
 
 	fromAccountAddress := &aptos.AccountAddress{}
 	err = fromAccountAddress.ParseStringRelaxed(fromAddress)
 	if err != nil {
-		a.baseLogger.Errorw("TestingAptosWriteCap: EnqueueCRE - failed to parse from address", "fromAddress", fromAddress, "error", err)
+		a.baseLogger.Errorw("TestingAptosWriteCap: EnqueueCRE - failed to parse from address", "fromAddress", utils.RedactAddress(fromAddress), "error", err)
 		return fmt.Errorf("failed to parse from address: %+w", err)
 	}
 
EOF
@@ -278,12 +278,12 @@

acc := utils.Ed25519PublicKeyToAddress(ed25519PublicKey)
fromAddress := acc.String()
a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", fromAddress)
a.baseLogger.Infow("TestingAptosWriteCap: EnqueueCRE - resolved from address", "fromAddress", utils.RedactAddress(fromAddress))

fromAccountAddress := &aptos.AccountAddress{}
err = fromAccountAddress.ParseStringRelaxed(fromAddress)
if err != nil {
a.baseLogger.Errorw("TestingAptosWriteCap: EnqueueCRE - failed to parse from address", "fromAddress", fromAddress, "error", err)
a.baseLogger.Errorw("TestingAptosWriteCap: EnqueueCRE - failed to parse from address", "fromAddress", utils.RedactAddress(fromAddress), "error", err)
return fmt.Errorf("failed to parse from address: %+w", err)
}

relayer/utils/address.go
Outside changed files

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/utils/address.go b/relayer/utils/address.go
--- a/relayer/utils/address.go
+++ b/relayer/utils/address.go
@@ -67,3 +67,14 @@
 
 	return Ed25519PublicKeyToAddress(ed25519.PublicKey(publicKey)), nil
 }
+
+// RedactAddress returns a partially obfuscated representation of an address string
+// suitable for logging without exposing the full underlying value.
+func RedactAddress(addr string) string {
+	const keep = 6
+	n := len(addr)
+	if n <= 2*keep {
+		return addr
+	}
+	return addr[:keep] + "..." + addr[n-keep:]
+}
EOF
@@ -67,3 +67,14 @@

return Ed25519PublicKeyToAddress(ed25519.PublicKey(publicKey)), nil
}

// RedactAddress returns a partially obfuscated representation of an address string
// suitable for logging without exposing the full underlying value.
func RedactAddress(addr string) string {
const keep = 6
n := len(addr)
if n <= 2*keep {
return addr
}
return addr[:keep] + "..." + addr[n-keep:]
}
Copilot is powered by AI and may make mistakes. Always verify output.

select {
case a.broadcastChan <- transactionID:
ctxLogger.Infow("TestingAptosWriteCap: EnqueueCRE - tx enqueued to broadcast channel", "fromAddr", fromAddress, "transactionID", transactionID)

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 about 4 hours ago

In general, to fix clear-text logging of sensitive information, you either (1) remove the sensitive data from logs entirely, or (2) obfuscate/redact it so logs retain usefulness without exposing full values. Here, the sensitive value is fromAddress, an account address string derived from an auth key. The safest change that preserves existing functionality is to stop logging the full fromAddress while leaving all transaction processing logic intact.

The single best fix is to modify the log line on line 325 in relayer/txm/txm.go so it no longer includes "fromAddr", fromAddress. Since the rest of the system may depend on this log message existing (e.g., for debugging or metrics parsing), we keep the log but only report non-sensitive fields like transactionID. There is already another log earlier (resolved from address) that also logs fromAddress; ideally that should also be adjusted, but the CodeQL alert specifically highlights line 325, so we will minimally fix that sink. No new imports or helpers are required; we simply adjust the arguments to Infow in the same file.

Concretely:

  • In relayer/txm/txm.go, locate the select block where the transaction ID is sent on a.broadcastChan.
  • Replace the Infow call on line 325 to remove the "fromAddr", fromAddress key/value pair, leaving just the message and "transactionID", transactionID.
  • No additional methods, types, or configuration are needed.
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
@@ -322,7 +322,7 @@
 
 	select {
 	case a.broadcastChan <- transactionID:
-		ctxLogger.Infow("TestingAptosWriteCap: EnqueueCRE - tx enqueued to broadcast channel", "fromAddr", fromAddress, "transactionID", transactionID)
+		ctxLogger.Infow("TestingAptosWriteCap: EnqueueCRE - tx enqueued to broadcast channel", "transactionID", transactionID)
 	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
@@ -322,7 +322,7 @@

select {
case a.broadcastChan <- transactionID:
ctxLogger.Infow("TestingAptosWriteCap: EnqueueCRE - tx enqueued to broadcast channel", "fromAddr", fromAddress, "transactionID", transactionID)
ctxLogger.Infow("TestingAptosWriteCap: EnqueueCRE - tx enqueued to broadcast channel", "transactionID", transactionID)
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