Skip to content

Commit 7fb44ca

Browse files
committed
Restrict permissions on materialized verify source.
1 parent 79dc60e commit 7fb44ca

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • cmd/soroban-cli/src/commands/contract

cmd/soroban-cli/src/commands/contract/verify.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ pub enum Error {
125125
#[error("creating tempdir: {0}")]
126126
TempDir(std::io::Error),
127127

128+
#[error("hardening permissions on {path}: {source}")]
129+
ChmodMaterialized {
130+
path: PathBuf,
131+
source: std::io::Error,
132+
},
133+
128134
#[error(transparent)]
129135
Verifiable(#[from] verifiable::Error),
130136

@@ -502,6 +508,16 @@ async fn materialize_source(
502508
print.checkln("Source SHA-256 matches");
503509
}
504510
extract_tarball(&bytes, target)?;
511+
512+
// Tighten the freshly materialized tree to 0o700 / 0o600 before docker
513+
// sees it. Uses the same per-path helper the cli already applies to its
514+
// config dirs (one source of truth for what "hardened" means).
515+
crate::config::locator::enforce_hardened_tree(target).map_err(|e| {
516+
Error::ChmodMaterialized {
517+
path: target.to_path_buf(),
518+
source: e,
519+
}
520+
})?;
505521
Ok(())
506522
}
507523

0 commit comments

Comments
 (0)