A simple implementation of a secure and serializable (serde and proto) type
of any kind of secrets:
- Automatically cleaning up its value after destruction in memory using zeroize;
- Prevents leaking in logs and stack traces;
- Stored as a byte array and suitable for binary secrets;
- Introduces additional functions with predicates to control the exposed border;
of exposed secret values and clean-ups: exposed_in_*
.
- Securely encoding/decoding from hex/base64 formats;
```rust use secretvaultvalue::*;
// Creating from string let secret_value: SecretValue = "test".into();
// Creating from vec let secret_value: SecretValue = vec![4,2].into();
// Creating from BytesMut let secret_value: SecretValue = bytes::BytesMut::from("test").into();
// Reading as string let secretvalue: &str = secretvalue4.assensitivestr();
// Reading as bytes let secretvalue: &[u8] = secretvalue.assensitivebytes();
// Reading as hex string
let secretvalue: Zeroizing
// Reading as base64 string
let secretvalue: Zeroizing
// Controlling the exposed value with closures/lambdas let yourresult = secretvalue.exposedinaszstr(|secretvalue|{ todo!() });
// Controlling the exposed value with async closures/lambdas let yourresult = secretvalue.exposedinaszstrasync(|secret_value| async { todo!() }).await;
// Deserialize embedded string value from JSON and expose it as zeroizable structure:
struct YourType { somefield: String }
let yourresultjson: YourType = secretvalue.exposejsonvalueas::
Cargo.toml:
toml
[dependencies]
secret-vault-type = { version = "0.3.<x>", features=["..."] }
See security consideration below about versioning.
serde
for serde serialization supportprost
for protobuf serialization supportbytes
for bytes conversion supporthex
for hex conversion supportbase64
for base64 conversion supportOpen source code is created through voluntary collaboration of software developers. The original authors license the code so that anyone can see it, modify it, and distribute new versions of it. You should manage all OSS using the same procedures and tools that you use for commercial products. As always, train your employees on cyber security best practices that can help them securely use and manage software products. You should not solely rely on individuals, especially on the projects like this reading sensitive information.
Please don't use broad version dependency management not to include a new version of dependency automatically without your auditing the changes.
Don't expose all of your secrets to the apps. Use IAM and different service accounts to give access only on as-needed basis.
There are still allocations on the protocol layers, there is a session secret key available in memory, privileged users on OS still have broad access, etc. So don't consider this is a completely safe solution for all possible attacks. Mitigation some of the attacks is not possible without implementing additional support on hardware/OS level (such as Intel SGX project, for instance).
Apache Software License (ASL)
Abdulla Abdurakhmanov