mirror of
https://github.com/rustfs/rustfs.git
synced 2026-12-03 06:36:35 +00:00
fix(sse): preserve content MD5 for SSE-S3 writes and parts
This commit is contained in:
@@ -135,14 +135,14 @@ enum ObjectShape {
|
||||
/// Single-part object uploaded with `x-amz-checksum-sha256`; the replica
|
||||
/// must carry the same header (rustfs/backlog#2340).
|
||||
Checksummed,
|
||||
/// Single-part SSE-S3 object. Its ETag is a keyed fingerprint, not the
|
||||
/// plaintext MD5 (docs/operations/encrypted-etags.md), while the replica
|
||||
/// travels as plaintext under `x-amz-server-side-encryption: AES256`.
|
||||
/// Single-part SSE-S3 with a content MD5.
|
||||
SseS3,
|
||||
/// Single-part SSE-KMS with an opaque ETag on the source.
|
||||
SseKms,
|
||||
}
|
||||
|
||||
impl ObjectShape {
|
||||
const ALL: [ObjectShape; 9] = [
|
||||
const ALL: [ObjectShape; 10] = [
|
||||
ObjectShape::Empty,
|
||||
ObjectShape::Plain,
|
||||
ObjectShape::Retention,
|
||||
@@ -152,6 +152,7 @@ impl ObjectShape {
|
||||
ObjectShape::OdmPreservedMd5Multipart,
|
||||
ObjectShape::Checksummed,
|
||||
ObjectShape::SseS3,
|
||||
ObjectShape::SseKms,
|
||||
];
|
||||
|
||||
fn key(self) -> &'static str {
|
||||
@@ -165,6 +166,7 @@ impl ObjectShape {
|
||||
ObjectShape::OdmPreservedMd5Multipart => "matrix/odm-preserved-md5.bin",
|
||||
ObjectShape::Checksummed => "matrix/checksummed.bin",
|
||||
ObjectShape::SseS3 => "matrix/sse-s3.bin",
|
||||
ObjectShape::SseKms => "matrix/sse-kms.bin",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,22 +250,24 @@ impl ObjectShape {
|
||||
.await?;
|
||||
Ok(body)
|
||||
}
|
||||
ObjectShape::SseS3 => {
|
||||
ObjectShape::SseS3 | ObjectShape::SseKms => {
|
||||
let body = payload(56 * 1024, 0x77);
|
||||
let algorithm = if self == ObjectShape::SseS3 {
|
||||
ServerSideEncryption::Aes256
|
||||
} else {
|
||||
ServerSideEncryption::AwsKms
|
||||
};
|
||||
let put = client
|
||||
.put_object()
|
||||
.bucket(bucket)
|
||||
.key(key)
|
||||
.body(ByteStream::from(body.clone()))
|
||||
.server_side_encryption(ServerSideEncryption::Aes256)
|
||||
.server_side_encryption(algorithm)
|
||||
.send()
|
||||
.await?;
|
||||
// The cell only proves something while the source ETag is
|
||||
// not the content MD5 a generic target reports back.
|
||||
let plaintext_md5 = hex_simd::encode_to_string(Md5::digest(&body), hex_simd::AsciiCase::Lower);
|
||||
if put.e_tag().map(|etag| etag.trim_matches('"')) == Some(plaintext_md5.as_str()) {
|
||||
return Err("SSE-S3 source ETag is the plaintext MD5; the cell no longer exercises encrypted ETags".into());
|
||||
}
|
||||
let source_etag = put.e_tag().ok_or("managed-SSE write returned no ETag")?.trim_matches('"');
|
||||
assert_eq!(source_etag == plaintext_md5, self == ObjectShape::SseS3, "{self:?}");
|
||||
Ok(body)
|
||||
}
|
||||
}
|
||||
@@ -311,7 +315,7 @@ async fn matrix_mint_own_version_ids_redrive_does_not_duplicate() -> TestResult
|
||||
run_redrive_does_not_duplicate(RedriveObjects::Plaintext).await
|
||||
}
|
||||
|
||||
/// The same re-drives for SSE-S3 objects against a target that also computes
|
||||
/// The same re-drives for SSE-KMS objects against a target that also computes
|
||||
/// its own ETags (AWS S3). The source ETag is a keyed fingerprint
|
||||
/// (docs/operations/encrypted-etags.md) while the replica reports the MD5 of
|
||||
/// the plaintext it received, so no exact-ETag lookup can ever find the
|
||||
@@ -319,18 +323,18 @@ async fn matrix_mint_own_version_ids_redrive_does_not_duplicate() -> TestResult
|
||||
/// without comparing ETags.
|
||||
#[tokio::test]
|
||||
async fn matrix_mint_own_version_ids_encrypted_redrive_does_not_duplicate() -> TestResult {
|
||||
run_redrive_does_not_duplicate(RedriveObjects::SseS3OnEtagComputingTarget).await
|
||||
run_redrive_does_not_duplicate(RedriveObjects::SseKmsOnEtagComputingTarget).await
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum RedriveObjects {
|
||||
Plaintext,
|
||||
SseS3OnEtagComputingTarget,
|
||||
SseKmsOnEtagComputingTarget,
|
||||
}
|
||||
|
||||
async fn run_redrive_does_not_duplicate(objects: RedriveObjects) -> TestResult {
|
||||
init_logging();
|
||||
let encrypted = objects == RedriveObjects::SseS3OnEtagComputingTarget;
|
||||
let encrypted = objects == RedriveObjects::SseKmsOnEtagComputingTarget;
|
||||
|
||||
let target = FakeS3Target::start().await?;
|
||||
let target_bucket = "matrix-mint-own-redrive-dst".to_string();
|
||||
@@ -388,7 +392,7 @@ async fn run_redrive_does_not_duplicate(objects: RedriveObjects) -> TestResult {
|
||||
.key(key)
|
||||
.body(ByteStream::from(payload(len, fill)));
|
||||
let request = if encrypted {
|
||||
request.server_side_encryption(ServerSideEncryption::Aes256)
|
||||
request.server_side_encryption(ServerSideEncryption::AwsKms)
|
||||
} else {
|
||||
request
|
||||
};
|
||||
@@ -1004,7 +1008,7 @@ async fn run_row(mode: TargetMode) -> TestResult {
|
||||
env_vars.extend_from_slice(&[("NO_PROXY", "127.0.0.1,localhost"), ("HTTP_PROXY", ""), ("HTTPS_PROXY", "")]);
|
||||
let env = OdmTestEnv::start_with(OdmEnvOptions {
|
||||
env: env_vars,
|
||||
// The SseS3 shape needs a KMS for SSE-S3.
|
||||
// Both managed-SSE shapes use the local KMS.
|
||||
local_kms: true,
|
||||
..OdmEnvOptions::default()
|
||||
})
|
||||
|
||||
@@ -354,9 +354,8 @@ fn replica_etag_verification_enabled() -> bool {
|
||||
/// mismatch fails the replication instead. Encrypted sources are exempt: an
|
||||
/// SSE-C ciphertext passthrough sends ciphertext while the source ETag is the
|
||||
/// plaintext MD5 (that path has its own HEAD-back audit), and a managed-SSE
|
||||
/// (SSE-S3 / SSE-KMS) source stores a keyed fingerprint, or a legacy plaintext
|
||||
/// MD5, that the ETag of the target's re-encrypted replica can neither confirm
|
||||
/// nor refute. A managed-SSE source forwards no checksum either
|
||||
/// source can carry either a content MD5 or an opaque fingerprint depending
|
||||
/// on its scheme and writer version. A target can assign its own ETag. A managed-SSE source forwards no checksum either
|
||||
/// (`replication_put_object_options`), so its replica has no post-PUT
|
||||
/// content audit.
|
||||
fn verify_single_part_replica(
|
||||
|
||||
@@ -31,6 +31,7 @@ use native as variant;
|
||||
pub use variant::*;
|
||||
|
||||
use rustfs_utils::CompressionAlgorithm;
|
||||
use rustfs_utils::http::object_encryption_keys::SSEType;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ReadCompressionBackend {
|
||||
@@ -61,6 +62,7 @@ pub enum ReadEncryptionBackend {
|
||||
pub struct WriteEncryption {
|
||||
key_bytes: [u8; 32],
|
||||
mode: WriteEncryptionMode,
|
||||
s3_content_etag: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@@ -83,6 +85,7 @@ impl WriteEncryption {
|
||||
Self {
|
||||
key_bytes: object_key,
|
||||
mode: WriteEncryptionMode::SinglepartObjectKey,
|
||||
s3_content_etag: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +93,7 @@ impl WriteEncryption {
|
||||
Self {
|
||||
key_bytes,
|
||||
mode: WriteEncryptionMode::Singlepart { base_nonce },
|
||||
s3_content_etag: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +104,7 @@ impl WriteEncryption {
|
||||
base_nonce,
|
||||
multipart_part_number,
|
||||
},
|
||||
s3_content_etag: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +112,31 @@ impl WriteEncryption {
|
||||
Self {
|
||||
key_bytes: object_key,
|
||||
mode: WriteEncryptionMode::MultipartObjectKey { multipart_part_number },
|
||||
s3_content_etag: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// SSE-S3 clients verify a single PUT or upload part against the MD5 of the original bytes.
|
||||
pub const fn for_sse_type(mut self, scheme: SSEType) -> Self {
|
||||
self.s3_content_etag = matches!(scheme, SSEType::SseS3);
|
||||
self
|
||||
}
|
||||
|
||||
fn encrypt(self, reader: impl rustfs_rio::Reader + 'static, actual_size: i64) -> std::io::Result<HashReader> {
|
||||
let key = self.key_bytes;
|
||||
let encrypted = match self.mode {
|
||||
WriteEncryptionMode::SinglepartObjectKey => variant::encrypt_under_object_key(reader, key),
|
||||
WriteEncryptionMode::Singlepart { base_nonce } => variant::encrypt_singlepart(reader, key, base_nonce),
|
||||
WriteEncryptionMode::MultipartLegacy {
|
||||
base_nonce,
|
||||
multipart_part_number,
|
||||
} => variant::encrypt_part(reader, key, base_nonce, multipart_part_number),
|
||||
WriteEncryptionMode::MultipartObjectKey { multipart_part_number } => {
|
||||
variant::encrypt_part_under_object_key(reader, key, multipart_part_number)
|
||||
}
|
||||
};
|
||||
HashReader::from_reader(encrypted, HashReader::SIZE_PRESERVE_LAYER, actual_size, None, None, false)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -148,6 +176,19 @@ impl WritePlan {
|
||||
|
||||
let delegate_inner_etag = self.compression.is_none() && reader.is_etag_reader();
|
||||
let encrypted = self.encryption.is_some();
|
||||
let s3_content_etag = self.encryption.is_some_and(|enc| enc.s3_content_etag);
|
||||
if s3_content_etag {
|
||||
// The incoming hash may be disabled or use a bucket-specific algorithm.
|
||||
// Hash the original stream so every SSE-S3 write has the same MD5 contract.
|
||||
reader = HashReader::from_reader(
|
||||
rustfs_rio::EtagReader::new(reader, None),
|
||||
HashReader::SIZE_PRESERVE_LAYER,
|
||||
actual_size,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
)?;
|
||||
}
|
||||
if let Some(algorithm) = self.compression {
|
||||
reader = HashReader::from_reader(
|
||||
compression_reader(reader, algorithm, encrypted),
|
||||
@@ -159,7 +200,11 @@ impl WritePlan {
|
||||
)?;
|
||||
}
|
||||
|
||||
if let Some(encryption) = self.encryption {
|
||||
if let Some(encryption) = self.encryption
|
||||
&& encryption.s3_content_etag
|
||||
{
|
||||
reader = encryption.encrypt(reader, actual_size)?;
|
||||
} else if let Some(encryption) = self.encryption {
|
||||
let etag_nonce = match encryption.mode {
|
||||
WriteEncryptionMode::Singlepart { base_nonce } => base_nonce,
|
||||
WriteEncryptionMode::SinglepartObjectKey => [0u8; 12],
|
||||
@@ -170,25 +215,13 @@ impl WritePlan {
|
||||
};
|
||||
let protected_reader = rustfs_rio::EtagReader::new_encrypted(reader, encryption.key_bytes, etag_nonce)?
|
||||
.with_inner_etag_delegation(delegate_inner_etag);
|
||||
let key = encryption.key_bytes;
|
||||
let encrypt_reader = match encryption.mode {
|
||||
WriteEncryptionMode::SinglepartObjectKey => variant::encrypt_under_object_key(protected_reader, key),
|
||||
WriteEncryptionMode::Singlepart { base_nonce } => variant::encrypt_singlepart(protected_reader, key, base_nonce),
|
||||
WriteEncryptionMode::MultipartLegacy {
|
||||
base_nonce,
|
||||
multipart_part_number,
|
||||
} => variant::encrypt_part(protected_reader, key, base_nonce, multipart_part_number),
|
||||
WriteEncryptionMode::MultipartObjectKey { multipart_part_number } => {
|
||||
variant::encrypt_part_under_object_key(protected_reader, key, multipart_part_number)
|
||||
}
|
||||
};
|
||||
reader = HashReader::from_reader(encrypt_reader, HashReader::SIZE_PRESERVE_LAYER, actual_size, None, None, false)?;
|
||||
reader = encryption.encrypt(protected_reader, actual_size)?;
|
||||
}
|
||||
|
||||
// `ignore_value` deliberately avoids a second hasher over compressed or
|
||||
// encrypted bytes. The inner reader still validates the plaintext request
|
||||
// checksum while this outer reader exposes the request checksum context.
|
||||
reader.encrypted_etag = encrypted;
|
||||
reader.encrypted_etag = encrypted && !s3_content_etag;
|
||||
reader.add_non_trailing_checksum(checksum, true)?;
|
||||
reader.set_trailer(trailer);
|
||||
|
||||
@@ -205,6 +238,35 @@ mod tests {
|
||||
use std::io::Cursor;
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
#[tokio::test]
|
||||
async fn sse_s3_content_etag_hashes_plaintext_before_compression_and_encryption() {
|
||||
let data = b"same bytes through each write plan";
|
||||
let size = data.len() as i64;
|
||||
let mut control = HashReader::from_stream(Cursor::new(data), size, size, None, None, false).unwrap();
|
||||
control.read_to_end(&mut Vec::new()).await.unwrap();
|
||||
let expected = control.try_resolve_etag().unwrap();
|
||||
for encryption in [
|
||||
WriteEncryption::singlepart([1; 32], [2; 12]),
|
||||
WriteEncryption::singlepart_object_key([1; 32]),
|
||||
WriteEncryption::multipart([1; 32], [2; 12], 1),
|
||||
WriteEncryption::multipart_object_key([1; 32], 1),
|
||||
] {
|
||||
for compress in [false, true] {
|
||||
let mut plan = WritePlan::new().with_encryption(encryption.for_sse_type(SSEType::SseS3));
|
||||
if compress {
|
||||
plan = plan.with_compression(CompressionAlgorithm::default());
|
||||
}
|
||||
let source = HashReader::from_stream(Cursor::new(data), size, size, None, None, false).unwrap();
|
||||
let mut reader = plan.apply(source, size).unwrap();
|
||||
let mut stored = Vec::new();
|
||||
reader.read_to_end(&mut stored).await.unwrap();
|
||||
assert_ne!(stored, data);
|
||||
assert_eq!(reader.try_resolve_etag().as_ref(), Some(&expected));
|
||||
assert!(!reader.encrypted_etag, "a plaintext MD5 cannot attest an opaque ETag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn write_plan_encryption_persists_protected_etags_for_every_mode() {
|
||||
let data = b"Salary 2026: 85000 EUR";
|
||||
|
||||
@@ -142,6 +142,7 @@ fn material_to_write_encryption(material: &EncryptionMaterial) -> SwiftWriteEncr
|
||||
EncryptionKeyKind::Object => SwiftWriteEncryption::singlepart_object_key(material.key_bytes),
|
||||
EncryptionKeyKind::Direct => SwiftWriteEncryption::singlepart(material.key_bytes, material.base_nonce),
|
||||
}
|
||||
.for_sse_type(material.sse_type)
|
||||
}
|
||||
|
||||
/// Map an [`SseError`] into a sanitized [`SwiftError`].
|
||||
|
||||
@@ -139,6 +139,13 @@ pub fn encryption_material_to_metadata(material: &EncryptionMaterial) -> Result<
|
||||
.as_deref()
|
||||
.ok_or_else(|| SseError::internal("managed SSE materials must carry an encrypted data key"))?;
|
||||
record_managed_scheme(&mut metadata, material);
|
||||
if material.sse_type == SSEType::SseS3 {
|
||||
rustfs_utils::http::metadata_compat::insert_str(
|
||||
&mut metadata,
|
||||
rustfs_utils::http::SUFFIX_SSE_S3_ETAG,
|
||||
"v1".to_owned(),
|
||||
);
|
||||
}
|
||||
|
||||
if material.key_kind == EncryptionKeyKind::Direct {
|
||||
record_wrapped_data_key(&mut metadata, wrapped_data_key, material.base_nonce, material.algorithm.as_str());
|
||||
@@ -239,6 +246,7 @@ pub fn strip_managed_encryption_metadata(metadata: &mut HashMap<String, String>)
|
||||
metadata.remove(*key);
|
||||
}
|
||||
rustfs_utils::http::metadata_compat::remove_str(metadata, rustfs_utils::http::SUFFIX_OPAQUE_ENCRYPTED_ETAG);
|
||||
rustfs_utils::http::metadata_compat::remove_str(metadata, rustfs_utils::http::SUFFIX_SSE_S3_ETAG);
|
||||
}
|
||||
|
||||
pub fn mark_encrypted_multipart_metadata(metadata: &mut HashMap<String, String>) {
|
||||
|
||||
@@ -73,13 +73,15 @@ pub const REPLICATION_SSE_SEALED_KEY_HEADER: &str = "X-Rustfs-Replication-Server
|
||||
pub const REPLICATION_ENCRYPTED_MULTIPART_HEADER: &str = "X-Rustfs-Replication-Encrypted-Multipart";
|
||||
|
||||
pub const SUFFIX_OPAQUE_ENCRYPTED_ETAG: &str = "server-side-encryption-opaque-etag";
|
||||
/// The writer selected SSE-S3's content ETag for this object or multipart session.
|
||||
pub const SUFFIX_SSE_S3_ETAG: &str = "server-side-encryption-s3-etag";
|
||||
|
||||
/// Old encrypted objects can carry a plaintext MD5. Keyless listings expose
|
||||
/// an encrypted ETag only when its producer recorded the protected format.
|
||||
/// Keyless listings require a writer marker for an opaque ETag or for the SSE-S3 content ETag.
|
||||
/// Legacy multipart original-size fields alone do not establish encryption.
|
||||
pub fn etag_can_be_listed(metadata: &HashMap<String, String>) -> bool {
|
||||
let mut requires_proof = false;
|
||||
let mut protected_format_seen = false;
|
||||
let mut s3_format_seen = false;
|
||||
for (key, value) in metadata {
|
||||
if super::metadata_compat::matches_either_internal_key_ignore_ascii_case(key, SUFFIX_OPAQUE_ENCRYPTED_ETAG) {
|
||||
// Every alias must attest the same protected format, even after a valid one.
|
||||
@@ -87,13 +89,30 @@ pub fn etag_can_be_listed(metadata: &HashMap<String, String>) -> bool {
|
||||
return false;
|
||||
}
|
||||
protected_format_seen = true;
|
||||
} else if super::metadata_compat::matches_either_internal_key_ignore_ascii_case(key, SUFFIX_SSE_S3_ETAG) {
|
||||
if value != "v1" {
|
||||
return false;
|
||||
}
|
||||
s3_format_seen = true;
|
||||
requires_proof = true;
|
||||
} else if !requires_proof && !protected_format_seen {
|
||||
requires_proof = super::is_object_encryption_marker(key)
|
||||
|| key.eq_ignore_ascii_case(SSEC_ORIGINAL_SIZE_HEADER)
|
||||
|| super::starts_with_ignore_ascii_case(key, RUSTFS_INTERNAL_ENCRYPTION_PREFIX);
|
||||
}
|
||||
}
|
||||
!requires_proof || protected_format_seen
|
||||
!requires_proof
|
||||
|| protected_format_seen
|
||||
|| (s3_format_seen
|
||||
&& metadata
|
||||
.get("x-amz-server-side-encryption")
|
||||
.is_some_and(|value| value == "AES256")
|
||||
&& contains_managed_encryption_metadata(metadata)
|
||||
&& !metadata.keys().any(|key| {
|
||||
super::starts_with_ignore_ascii_case(key, "x-amz-server-side-encryption-customer-")
|
||||
|| key.eq_ignore_ascii_case(MINIO_INTERNAL_ENCRYPTION_SSEC_SEALED_KEY_HEADER)
|
||||
|| key.eq_ignore_ascii_case("x-amz-server-side-encryption-aws-kms-key-id")
|
||||
}))
|
||||
}
|
||||
|
||||
/// Stored SSE-C metadata keys and the wire names they replicate under.
|
||||
@@ -359,6 +378,22 @@ mod tests {
|
||||
assert!(etag_can_be_listed(&both_sizes));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keyless_listings_require_the_sse_s3_writer_marker_and_scheme() {
|
||||
let mut metadata = HashMap::from([
|
||||
("x-amz-server-side-encryption".to_owned(), "AES256".to_owned()),
|
||||
(INTERNAL_ENCRYPTION_KEY_HEADER.to_owned(), "wrapped".to_owned()),
|
||||
]);
|
||||
assert!(!etag_can_be_listed(&metadata));
|
||||
super::super::metadata_compat::insert_str(&mut metadata, SUFFIX_SSE_S3_ETAG, "v1".to_owned());
|
||||
assert!(etag_can_be_listed(&metadata));
|
||||
metadata.insert(SSEC_ALGORITHM_HEADER.to_owned(), "AES256".to_owned());
|
||||
assert!(!etag_can_be_listed(&metadata));
|
||||
metadata.remove(SSEC_ALGORITHM_HEADER);
|
||||
metadata.insert("x-amz-server-side-encryption".to_owned(), "aws:kms".to_owned());
|
||||
assert!(!etag_can_be_listed(&metadata));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keyless_listings_hide_unproven_encrypted_etags() {
|
||||
assert!(etag_can_be_listed(&HashMap::from([("content-type".to_owned(), "text/plain".to_owned())])));
|
||||
|
||||
@@ -3,15 +3,26 @@
|
||||
**Use this when:** upgrading encrypted storage or investigating missing ETags
|
||||
in object listings after an upgrade.
|
||||
|
||||
New encrypted writes use a keyed fingerprint for the ETag rather than the
|
||||
plaintext MD5. Single-part and part ETags are 32-character hexadecimal values;
|
||||
completed multipart ETags retain their digest-and-part-count form. They stay
|
||||
stable for the stored object. Request MD5 and checksum validation still apply
|
||||
to the original plaintext. Encryption and decryption formats do not change.
|
||||
New single-part SSE-S3 writes return the MD5 of the original bytes, including
|
||||
when a bucket default selects AES256. Clients such as rclone use this value to
|
||||
verify uploads. SSE-S3 parts use the same content MD5 and their completed
|
||||
ETag combines the part digests and part count. SSE-C and SSE-KMS writes use
|
||||
keyed fingerprints. Request checksums cover the original plaintext in every
|
||||
mode. [Amazon S3 ETag semantics](https://docs.aws.amazon.com/AmazonS3/latest/API/API_Object.html)
|
||||
|
||||
## Listings and older objects
|
||||
|
||||
ListObjects, ListObjectsV2, and ListObjectVersions omit the optional ETag field for encrypted objects whose metadata does not attest to the protected format. This includes older encrypted objects and preserved source ETags without that proof. New single-part encrypted writes carry the internal format marker and expose their protected ETag in listings. Completed encrypted multipart uploads also carry that marker when every selected part has quorum-backed proof that its stored ETag came from the encryption reader and the final ETag is the aggregate of those parts. Unencrypted listings retain their existing ETags.
|
||||
ListObjects, ListObjectsV2 and ListObjectVersions expose the stored ETag of an
|
||||
SSE-S3 object created through the new writer. The same ETag appears on GET and
|
||||
HEAD and in conditional requests. Earlier versions keep their stored ETags
|
||||
and listing visibility, including opaque SSE-S3 fingerprints. Old writers can
|
||||
omit the listing ETag for objects created by a new SSE-S3 writer during a
|
||||
rolling upgrade. Older encrypted objects without a format marker require HEAD.
|
||||
|
||||
SSE-C and SSE-KMS expose keyed ETags in listings when the producer recorded
|
||||
the protected format. Completed multipart uploads can attest an opaque ETag
|
||||
when every selected part has quorum-backed proof and the final ETag matches
|
||||
the aggregate of those parts.
|
||||
|
||||
Each new encrypted part records its producer proof in optional part metadata. Older part metadata defaults to unproven. Mixing proven and unproven selected parts, or preserving a different source ETag, keeps the completed object unproven. The proof is checked during completion using the existing part metadata reads, so listings need no additional object reads or KMS requests. Internal same-version data movement, including rebalance and decommission, retains an existing source proof when quorum-validated staging metadata and the completed object agree on the version and preserved ETag. Tier restore also retains the proof for the same version and ETag when it commits under the matching restore operation. Sources without proof continue to require authorized HEAD access or a credentialed rewrite.
|
||||
|
||||
@@ -21,10 +32,9 @@ Clients that require an ETag for unproven objects must issue an authorized HeadO
|
||||
|
||||
Bucket and site replication forward the stored ETag on `x-rustfs-source-etag`
|
||||
(with its `x-minio-source-*` twin). A target that adopts it (RustFS, MinIO)
|
||||
reports the fingerprint for the replica; a target that computes its own ETag
|
||||
(AWS S3 and most compatible stores) reports the MD5 of the plaintext it
|
||||
received, which never equals the fingerprint. The post-PUT replica ETag audit
|
||||
therefore skips encrypted sources. Managed-SSE sources forward no checksum on
|
||||
reports that ETag for the replica. A target that computes its own ETag can
|
||||
return a different value for SSE-KMS or for an older SSE-S3 source. The
|
||||
post-PUT replica ETag audit skips encrypted sources. Managed-SSE sources forward no checksum on
|
||||
the replication PUT either, so a target that transforms their payload is not
|
||||
detected. See
|
||||
`docs/operations/replication-outbound-transport.md`.
|
||||
@@ -62,8 +72,9 @@ already copied to backups, logs, caches, or replicas. Restrict access to those
|
||||
copies separately. Rolling back to an older server also restores its listing
|
||||
behavior, so keep the upgraded listing protection on every serving node.
|
||||
|
||||
To obtain a protected ETag, read the object with its encryption credentials and
|
||||
write it through the upgraded encryption path. Verify the resulting plaintext
|
||||
To migrate an older SSE-S3 object to a content MD5, read it with authorization
|
||||
and upload it through the new SSE-S3 writer. SSE-C and SSE-KMS use the same
|
||||
procedure to migrate to a protected ETag. Verify the resulting plaintext
|
||||
and application references before retiring an old copy. A server-side copy
|
||||
that preserves the source ETag is insufficient.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
- For a single-part object, the checksum the source object was uploaded with, forwarded as its `x-amz-checksum-<algorithm>` header (the value the source verified on upload). A multipart replica is rebuilt through CreateMultipartUpload/UploadPart and carries no object-level checksum header. Managed-SSE objects forward none.
|
||||
- On a PUT that carries Object Lock parameters and no forwarded checksum: `Content-MD5` derived from the source ETag, or an SDK CRC32 checksum when the ETag is not the MD5 of the wire bytes (rustfs#7082).
|
||||
- The source ETag, mtime and version id on `x-rustfs-source-*` headers (with `x-minio-source-*` twins), and the Object Lock mode, retain-until date and legal hold of the source version when present.
|
||||
- After the PUT, the target's ETag is compared with the source ETag when both are plain single-part MD5s and the source is unencrypted; a mismatch fails the replication instead of reporting a corrupted replica as COMPLETED. A managed-SSE (SSE-S3 / SSE-KMS) or SSE-C source is not audited this way: its stored ETag is a keyed fingerprint (new writes, see `docs/operations/encrypted-etags.md`) or a legacy plaintext MD5, and the target re-encrypts what it receives, so the two ETags are never comparable. Managed-SSE sources also forward no checksum (above), so a target that transforms their payload is not detected; an SSE-C ciphertext passthrough keeps its HEAD-back evidence audit.
|
||||
- After the PUT, the target's ETag is compared with the source ETag when both are plain single-part MD5s and the source is unencrypted; a mismatch fails the replication instead of reporting a corrupted replica as COMPLETED. A managed-SSE (SSE-S3 / SSE-KMS) or SSE-C source is not audited this way: old SSE-S3 and SSE-KMS versions can have keyed fingerprints, new SSE-S3 writes have content MD5s, and a target can return its own ETag. See `docs/operations/encrypted-etags.md`. Managed-SSE sources also forward no checksum (above), so a target that transforms their payload is not detected; an SSE-C ciphertext passthrough keeps its HEAD-back evidence audit.
|
||||
|
||||
## Target classes and their known requirements
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ impl DefaultMultipartUsecase {
|
||||
WriteEncryption::multipart(managed_material.key_bytes, managed_material.base_nonce, part_id)
|
||||
}
|
||||
};
|
||||
write_plan = write_plan.with_encryption(managed_write);
|
||||
write_plan = write_plan.with_encryption(managed_write.for_sse_type(managed_material.sse_type));
|
||||
(Some(server_side_encryption), ssekms_key_id)
|
||||
} else {
|
||||
(None, None)
|
||||
|
||||
@@ -469,7 +469,7 @@ impl DefaultMultipartUsecase {
|
||||
WriteEncryption::multipart(managed_material.key_bytes, managed_material.base_nonce, part_id)
|
||||
}
|
||||
};
|
||||
write_plan = write_plan.with_encryption(managed_write);
|
||||
write_plan = write_plan.with_encryption(managed_write.for_sse_type(managed_material.sse_type));
|
||||
(Some(server_side_encryption), ssekms_key_id)
|
||||
} else {
|
||||
(None, None)
|
||||
|
||||
@@ -549,7 +549,7 @@ impl DefaultObjectUsecase {
|
||||
WriteEncryption::multipart(managed_material.key_bytes, managed_material.base_nonce, part_number)
|
||||
}
|
||||
};
|
||||
write_plan = write_plan.with_encryption(managed_write);
|
||||
write_plan = write_plan.with_encryption(managed_write.for_sse_type(managed_material.sse_type));
|
||||
}
|
||||
|
||||
reader = write_plan.apply(reader, actual_size).map_err(ApiError::from)?;
|
||||
|
||||
@@ -510,6 +510,7 @@ impl EncryptionMaterialExt for EncryptionMaterial {
|
||||
}
|
||||
(EncryptionKeyKind::Direct, None) => WriteEncryption::singlepart(self.key_bytes, self.base_nonce),
|
||||
}
|
||||
.for_sse_type(self.sse_type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user