Skip to content

TEE Registry Management CLI tool - #26

Merged
adambalogh merged 7 commits into
mainfrom
kha/improve-integrationTests
Mar 6, 2026
Merged

TEE Registry Management CLI tool#26
adambalogh merged 7 commits into
mainfrom
kha/improve-integrationTests

Conversation

@khalifaT

Copy link
Copy Markdown
Collaborator

Description

Adds TEE Registry Management CLI tool for managing Trusted Execution Environment registration, attestation, and role-based access control on OpenGradient blockchain.
This CLI provides a complete command-line interface for:

  • TEE Operations: List, show, register, activate, and deactivate TEEs
  • PCR Management: Approve, revoke, check, and compute PCR hashes
  • Type Management: List, add, and deactivate TEE types
  • Role Management: Grant/revoke admin and operator roles
  • Certificate Management: Set AWS root certificates

@khalifaT
khalifaTforce-pushed the kha/improve-integrationTests branch from 1935e6f to 7e7c46dCompareMarch 4, 2026 11:08
@khalifaT
khalifaT marked this pull request as ready for review March 4, 2026 15:28
@adambalogh

adambalogh commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

@khalifaT can you use a more descriptive PR title? It doesn't look like this PR has anything to do with integration tests

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new TEE (Trusted Execution Environment) Registry Management CLI tool under scripts/tee-mgmt-cli/ for interacting with the OpenGradient blockchain's TEE registry smart contract. It also updates the local_tee_workflow.go integration test to point to a remote RPC endpoint instead of localhost.

Changes:

  • New register-mgmt.go CLI providing commands for TEE lifecycle, PCR management, type management, role management, and AWS certificate operations.
  • New documentation (Readme.md), configuration example (.env.example), and .gitignore for the CLI tool.
  • Updated RPC_URL constant in local_tee_workflow.go from http://127.0.0.1:8545 to a remote IP.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.

Show a summary per file
FileDescription
scripts/tee-mgmt-cli/register-mgmt.goNew CLI tool implementing all TEE registry management commands via Ethereum JSON-RPC
scripts/tee-mgmt-cli/Readme.mdUsage documentation for the CLI
scripts/tee-mgmt-cli/.env.exampleTemplate environment configuration file
scripts/tee-mgmt-cli/.gitignoreIgnores built binary and .env secrets file
scripts/integration/local_tee_workflow.goChanges the "local" integration test RPC URL from localhost to a remote server IP

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadscripts/tee-mgmt-cli/register-mgmt.go
Comment on lines +913 to +946
func fetchAttestation(url string) (string, error) {
client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}, Timeout: 30 * time.Second}
resp, err := client.Get(url)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
return string(bytes.TrimSpace(body)), nil
}

func fetchSigningPublicKey(host string) ([]byte, error) {
client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}, Timeout: 30 * time.Second}
resp, err := client.Get(fmt.Sprintf("https://%s/signing-key", host))
if err != nil {
return nil, err
}
defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)
var data AttestationResponse
json.Unmarshal(body, &data)

if block, _ := pem.Decode([]byte(data.PublicKey)); block != nil {
return block.Bytes, nil
}
if decoded, err := base64.StdEncoding.DecodeString(data.PublicKey); err == nil {
return decoded, nil
}
return nil, fmt.Errorf("invalid key format")
}

func fetchTLSCertificate(host, port string) ([]byte, error) {
conn, err := tls.Dial("tcp", host+":"+port, &tls.Config{InsecureSkipVerify: true})

CopilotAIMar 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both fetchAttestation and fetchSigningPublicKey use InsecureSkipVerify: true in their TLS configurations. While the attestation document itself might serve as an integrity check, skipping TLS verification means that the connection is susceptible to man-in-the-middle attacks. An attacker could intercept the connection and substitute a malicious attestation document or signing key, potentially allowing an unauthorized TEE to be registered. Since this is a dev/script tool, this should at minimum be documented clearly, and ideally the tool should provide an option to supply a CA certificate for proper verification.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the developer pass in the certificate?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adambalogh

Do you mean that they should be included in the attestation? If so, the attestation already includes the hash of both of them.

Regarding InsecureSkipVerify: this is due to how the certificates are generated by AWS Nitro. I'm not sure whether we can improve this (@kylexqian).

In the precompile, the certificate chain is validated against the AWS Nitro root. The attestation document contains the hashes of the TLS certificate and the signing public key, which are later compared with the values fetched via fetchAttestation / fetchSigningPublicKey. For the public key, this still needs to be added.

  • A possible improvement would be to validate that our verifyCOSESignatureES384 implementation works correctly by cross-testing it with AWS’s reference verifier, or by replacing it with a library such as go-cose.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no i mean shouldn't the certificate be passed in to the script?

Comment threadscripts/tee-mgmt-cli/Readme.md Outdated
Comment threadscripts/tee-mgmt-cli/register-mgmt.go Outdated
Comment threadscripts/integration/local_tee_workflow.go
Comment threadscripts/tee-mgmt-cli/register-mgmt.go Outdated
Comment threadscripts/tee-mgmt-cli/register-mgmt.go
Comment threadscripts/tee-mgmt-cli/register-mgmt.go
Comment threadscripts/tee-mgmt-cli/register-mgmt.go Outdated
Comment threadscripts/tee-mgmt-cli/register-mgmt.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
./tee-cli show <tee_id>

# Register new TEE from enclave
./tee-cli register

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels like it would be more natural to pass in the TEE arguments to this command as opposed to setting them as env vars

|----------|-------------|---------|
| `TEE_RPC_URL` | RPC endpoint | `http://13.59.43.94:8545` |
| `TEE_REGISTRY_ADDRESS` | Contract address | `0x3d641a2791533b4a...` |
| `TEE_PRIVATE_KEY` | Private key for signing | (uses node account if empty) |

@adambaloghadambaloghMar 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is node account?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If TEE_PRIVATE_KEY is not set, the CLI uses eth_sendTransaction RPC method, which requires the node to have an unlocked account. This is only for development but not for production.

  • I may delete that if needed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not understand what is a node/unlocked account, can you clarify in docs or remove?

Comment threadscripts/tee-mgmt-cli/Readme.md
| `TEE_PRIVATE_KEY` | Private key for signing | (uses node account if empty) |
| `ENCLAVE_HOST` | Enclave hostname | - |
| `ENCLAVE_PORT` | Enclave port | `443` |
| `MEASUREMENTS_FILE` | Path to measurements.txt | `measurements.txt` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add more explanation around this? what should be the content of this file?

./tee-cli pcr-approve

# From environment variables
PCR0=abc123... PCR1=def456... PCR2=789... PCR_VERSION=v1.0.0 ./tee-cli pcr-approve

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be better as cli params ./tee-cli pcr-approve --pcr0 abc1234 ...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use a lib like this https://github.com/spf13/cobra

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other cli tools also use this

funcNewRawTxCmd() *cobra.Command {

@khalifaTkhalifaT changed the title Kha/improve integration tests TEE Registry Management CLI toolMar 6, 2026
@khalifaTkhalifaT mentioned this pull request Mar 6, 2026
4 tasks
@adambalogh
adambalogh merged commit 5ba320b into mainMar 6, 2026
Sign up for freeto 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.

3 participants

@khalifaT@adambalogh