Skip to content

Commit

Permalink
Fix some audit issues
Browse files Browse the repository at this point in the history
This commit fixes 2 audit issues present in the celestia compatible
integration. Specifically, issues #6 and #7
  • Loading branch information
zacshowa committed Dec 19, 2024
1 parent f1da446 commit dde2cb3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions arbnode/transaction_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import (
"github.com/offchainlabs/nitro/util/sharedmetrics"
"github.com/offchainlabs/nitro/util/stopwaiter"
)

const UserDataAttestationFile = "//dev/attestation/user_report_data"
const QuoteFile = "/dev/attestation/quote"
// TransactionStreamer produces blocks from a node's L1 messages, storing the results in the blockchain and recording their positions
// The streamer is notified when there's new batches to process
type TransactionStreamer struct {
Expand Down Expand Up @@ -1600,6 +1601,9 @@ func (s *TransactionStreamer) HasNotSubmitted(pos arbutil.MessageIndex) (bool, e

// Append a position to the pending queue. Please ensure this position is valid beforehand.
func (s *TransactionStreamer) SubmitEspressoTransactionPos(pos arbutil.MessageIndex, batch ethdb.Batch) error {
s.espressoTxnsStateInsertionMutex.Lock()
defer s.espressoTxnsStateInsertionMutex.Unlock()

pendingTxnsPos, err := s.getEspressoPendingTxnsPos()
if err != nil {
return err
Expand Down Expand Up @@ -1836,9 +1840,6 @@ func (s *TransactionStreamer) Start(ctxIn context.Context) error {
* The quote is then read from the file specified in the config. (For SGX: /dev/attestation/quote)
*/
func (t *TransactionStreamer) getAttestationQuote(userData []byte) ([]byte, error) {
if (t.config().UserDataAttestationFile == "") || (t.config().QuoteFile == "") {
return []byte{}, nil
}

// keccak256 hash of userData
userDataHash := crypto.Keccak256(userData)
Expand All @@ -1850,13 +1851,13 @@ func (t *TransactionStreamer) getAttestationQuote(userData []byte) ([]byte, erro
}

// Write the message to "/dev/attestation/user_report_data" in SGX
err := os.WriteFile(t.config().UserDataAttestationFile, userDataHash, 0600)
err := os.WriteFile(UserDataAttestationFile, userDataHash, 0600)
if err != nil {
return []byte{}, fmt.Errorf("failed to create user report data file: %w", err)
}

// Read the quote from "/dev/attestation/quote" in SGX
attestationQuote, err := os.ReadFile(t.config().QuoteFile)
attestationQuote, err := os.ReadFile(QuoteFile)
if err != nil {
return []byte{}, fmt.Errorf("failed to read quote file: %w", err)
}
Expand Down

0 comments on commit dde2cb3

Please sign in to comment.