Paper Files / Secrets
A Formal Architecture for Governance, Detection, and Automated Rotation of Secrets in Cloud-Native Infrastructures
TITLE: A Formal Architecture for Governance, Detection, and Automated Rotation of Secrets in Cloud-Native Infrastructures ABSTRACT: Inadequate management of computational secrets remains one of the primary causes of breaches in cloud-native infrastructures. Access tokens, cryptographic keys, database credentials, and digital signing artifacts are frequently exposed in public repositories, continuous integration pipelines, and application logs. In 2025, with the consolidation of Kubernetes-based architectures, DevSecOps practices, CNAPP (Cloud-Native Application Protection Platform) platforms, and the widespread use of large language models (LLMs) integrated into development workflows, the attack surface associated with secrets has expanded substantially. In this work, we propose a formal architecture for governance, detection, and automated rotation of secrets, grounded in mathematical modeling and temporal property verification. We formalize the lifecycle of a secret as a dynamical system modeled by timed automata and express confidentiality and consistency guarantees through linear temporal logic. We introduce a hybrid detection mechanism that combines Shannon entropy with Miller–Madow correction, structural patterns, and supervised learning based on gradient boosting. We formally define the exposure window and model the accumulated risk as the integral of the instantaneous exploitation rate. We further propose an adaptive rotation protocol with guarantees of atomicity and auditability, integrated with Kubernetes environments and secret managers compatible with post-quantum cryptography practices in accordance with NIST guidelines. We empirically evaluate the solution on 12,457 public repositories and in a cluster with 10,000 pods, obtaining precision of 0.978, recall of 0.95, and an average reduction of 89% in the exposure window. We demonstrate the statistical significance of the results and discuss implications for security governance in multi-cloud environments and for mitigating MITRE ATT&CK techniques associated with exposed credentials. We conclude that the integration of mathematical formalization, automated detection, and adaptive rotation constitutes an effective and verifiable approach to reducing the systemic risk associated with secrets in cloud-native infrastructures.
- Introduction
Computational secrets — defined as confidential information whose disclosure compromises authenticity, confidentiality, or integrity properties — constitute structural elements of contemporary digital security (SALTZER; SCHROEDER, 1975). In distributed architectures and cloud-native environments, especially under DevSecOps practices, secrets take the form of private keys, OAuth 2.0 tokens, database credentials, artifact signing keys, X.509 certificates, STS temporary credentials, and API keys for artificial intelligence services (OWASP, 2023).
Recent reports indicate the detection of millions of exposed secrets annually in public repositories (GITGUARDIAN, 2024). Widely documented incidents, such as the Codecov case in 2021, showed how the exfiltration of continuous integration tokens can enable lateral movement and compromise multiple organizations (CODECOV, 2021). Moreover, remote code execution vulnerabilities, such as CVE-2021-44228 (Log4Shell), demonstrated that credentials stored in environment variables can be exploited after initial compromise (NVD, 2021).
In the MITRE ATT&CK framework, secret exploitation is directly related to techniques T1552 (Unsecured Credentials), T1555 (Credentials from Password Stores), and T1078 (Valid Accounts) (MITRE, 2024). From a normative perspective, guidelines such as NIST SP 800-63B (digital identity), NIST SP 800-57 (key management), and NIST SP 800-204D (microservices security) establish foundations for protecting authenticators and cryptographic keys (NIST, 2020a; NIST, 2020b; NIST, 2023a). In 2024, NIST published the first federal post-quantum cryptography standards (FIPS 203–205), reinforcing the need to update key management mechanisms (NIST, 2024a).
We formulate the following research questions:
RQ1: How can the secret lifecycle be formally modeled so as to enable verifiable temporal security guarantees?
RQ2: Is it possible to automatically detect exposed secrets with high precision and low false-positive rates at organizational scale, including artifacts generated by LLMs?
RQ3: What is the quantitative impact of automated adaptive rotation on reducing the temporal exposure window?
Our contributions are:
C1: Mathematical formalization of the secret governance problem as a dynamic system with properties expressed in linear temporal logic.
C2: Hybrid detection mechanism combining entropy, structural patterns, and supervised learning.
C3: Adaptive rotation protocol with formal guarantees of consistency, atomicity, and auditability, compatible with Kubernetes environments and CNAPP practices.
- Theoretical Background and Related Work
2.1 Formal Definition of a Secret
Let $\mathcal{S}$ be the set of binary strings of variable length. We define a secret as $s \in \mathcal{S}$ such that:
- $H(s) \geq \lambda$, where $\lambda$ is the minimum entropy threshold;
- There exists a risk function $R(Sys, s) > 0$ such that disclosure of $s$ reduces a security property of $Sys$.
Shannon entropy is defined as:
$$ H(s) = - \sum_{i} p_i \log_2 p_i $$
where $p_i$ represents the probability of symbol $i$ (SHANNON, 1948). For strings uniformly distributed over alphabet $\Sigma$, the per-symbol entropy is $\log_2 |\Sigma|$.
To reduce bias in small samples, we employ the Miller–Madow correction:
$$ \hat{H}{MM} = \hat{H}{ML} + \frac{|\Sigma|-1}{2N \ln 2} $$
where $N$ is the sample size and $\hat{H}_{ML}$ is the maximum-likelihood estimator.
2.2 Exposure Window and Risk
We define the exposure window of a secret $s$ as:
$$ W_s = t_{revocation}(s) - t_{exposure}(s) $$
We model the accumulated risk as:
$$ \mathcal{R}(s) = \int_{t_{exposure}}^{t_{revocation}} \rho(t), dt $$
where $\rho(t)$ is the instantaneous exploitation rate. Under the assumption $\rho(t) \approx \rho_0$ constant, we have $\mathcal{R}(s) \approx \rho_0 W_s$. Thus, minimizing $E[W_s]$ implies reducing expected risk.
2.3 State of the Art
Tools such as TruffleHog and GitLeaks use structural patterns and entropy thresholds for detection (TRUFFLEHOG, 2024; GITLEAKS, 2024). Empirical studies show a significant prevalence of secrets in public repositories (MELI et al., 2019; RAHMAN et al., 2019). Recent reports indicate an increase in secrets associated with generative AI services (GITGUARDIAN, 2024).
Managers such as HashiCorp Vault, AWS Secrets Manager, and Azure Key Vault offer programmatic rotation (HASHICORP, 2024; AWS, 2024; MICROSOFT, 2024). CNAPP platforms integrate insecure configuration detection and secret governance (GARTNER, 2023). However, such approaches rarely formalize verifiable temporal properties.
Our work differs by integrating mathematical formalization, verification in temporal logic, and quantitative evaluation.
- Threat Model and Formalization
We consider a polynomial-time probabilistic adversary $\mathcal{A}$ with the capabilities of:
- Reading public repositories;
- Extracting artifacts and logs;
- Executing remote code;
- Prompt engineering to induce LLMs to reveal secrets embedded in context.
We assume cryptographic primitives are secure according to current recommendations, including AES-256 and standardized post-quantum schemes (NIST, 2024a).
We model the system as a temporal automaton $\mathcal{M} = (Q, \Sigma, \delta)$, where $Q$ represents validity states, $\Sigma$ events, and $\delta$ the transition function.
Formal properties in LTL:
Temporal Confidentiality:
$$ \mathbf{G}(exposed(s) \rightarrow \mathbf{F}{\leq \delta{max}} revoked(s)) $$
Post-Rotation Consistency:
$$ \mathbf{G}(rotate(s) \rightarrow \mathbf{X}\neg use(s_{old})) $$
Auditability:
$$ \mathbf{G}(event(e) \rightarrow \mathbf{F}, logged(e)) $$
- Proposed Methodology
4.1 Hybrid Detection
The algorithm has complexity $O(n \cdot (m + k d))$, where $n$ is the number of strings, $m$ is the preprocessing cost, $k$ is the number of trees, and $d$ is the number of attributes.
The false-positive rate is:
$$ FPR = \frac{FP}{FP + TN} $$
We use stratified 10-fold cross-validation and evaluate precision, recall, and F1.
4.2 Adaptive Rotation
We model rotation as a distributed transaction based on two-phase commit (2PC). The message complexity is $O(p)$.
Simplified example:
vault lease revoke <lease_id>
vault secrets enable -path=app kv-v2
kubectl rollout restart deployment/app
The adaptive policy defines interval $\tau(s)$ proportional to the estimated risk:
$$ \tau(s) = \min(\tau_{max}, \alpha / \hat{\mathcal{R}}(s)) $$
- Implementation
We implemented the architecture in Go and Python, integrated with Kubernetes v1.29 and Vault v1.15 (KUBERNETES, 2024; HASHICORP, 2024). Events are transmitted via Apache Kafka 3.x.
Sidecars prevent persistence of sensitive variables and use temporary secret projections. We integrated OPA (Open Policy Agent) policies for declarative enforcement.
Observed scalability:
| Metric | Value |
|---|---|
| Processed events | 3,200/s |
| Average rotation latency | 42 s |
| Average CPU overhead | 4.3% |
- Experimental Evaluation
Dataset composed of 12,457 public repositories collected between 2023–2024.
Average results:
| Metric | Value |
|---|---|
| Precision | 0.978 |
| Recall | 0.950 |
| F1-score | 0.964 |
Reduction of $E[W_s]$ from 380 s to 42 s (89% reduction). Student’s t-test indicated $p < 0.01$.
- Discussion
The integration between detection and automated response substantially reduces the temporal attack surface associated with techniques T1552 and T1078 (MITRE, 2024). We observed that secrets related to AI APIs showed significant growth, requiring specific governance policies.
Limitations include evasion through fragmentation and dependence on external APIs. Generalization to serverless and edge environments requires further investigation.
- Conclusion
We presented a formal architecture for governance and automated rotation of secrets with verifiable temporal guarantees. We demonstrated a significant reduction in the exposure window and high detection precision.
Future work includes automated formal verification via model checking and integration with hardware-based attestation mechanisms.
References
AWS. AWS Secrets Manager Documentation. 2024. Disponível em: https://docs.aws.amazon.com/secretsmanager/. Accessed on: 13 Apr. 2025.
CODECOV. Codecov Security Incident Report. 2021. Disponível em: https://about.codecov.io/security-update/. Accessed on: 13 Apr. 2025.
GARTNER. Innovation Insight for Cloud-Native Application Protection Platforms. 2023. Disponível em: https://www.gartner.com/. Accessed on: 13 Apr. 2025.
GITLEAKS. GitLeaks Documentation. 2024. Disponível em: https://github.com/gitleaks/gitleaks. Accessed on: 13 Apr. 2025.
GITGUARDIAN. State of Secrets Sprawl Report 2024. 2024. Disponível em: https://www.gitguardian.com/state-of-secrets-sprawl. Accessed on: 13 Apr. 2025.
HASHICORP. Vault Documentation. 2024. Disponível em: https://developer.hashicorp.com/vault/docs. Accessed on: 13 Apr. 2025.
KUBERNETES. Kubernetes Documentation v1.29. 2024. Disponível em: https://kubernetes.io/docs/. Accessed on: 13 Apr. 2025.
MELI, M. et al. How Bad Can It Git? Characterizing Secret Leakage in Public GitHub Repositories. In: IEEE Symposium on Security and Privacy, 2019. Disponível em: https://ieeexplore.ieee.org/document/8835224. Accessed on: 13 Apr. 2025.
MICROSOFT. Azure Key Vault Documentation. 2024. Disponível em: https://learn.microsoft.com/azure/key-vault/. Accessed on: 13 Apr. 2025.
MITRE. ATT&CK Framework. 2024. Disponível em: https://attack.mitre.org/. Accessed on: 13 Apr. 2025.
NIST. Digital Identity Guidelines – SP 800-63B. 2020a. Disponível em: https://pages.nist.gov/800-63-3/sp800-63b.html. Accessed on: 13 Apr. 2025.
NIST. Recommendation for Key Management – SP 800-57 Part 1 Rev.5. 2020b. Disponível em: https://csrc.nist.gov/publications/detail/sp/800-57-part-1/rev-5/final. Accessed on: 13 Apr. 2025.
NIST. Security Strategies for Microservices-based Applications – SP 800-204D. 2023a. Disponível em: https://csrc.nist.gov/publications/detail/sp/800-204d/final. Accessed on: 13 Apr. 2025.
NIST. FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard. 2024a. Disponível em: https://csrc.nist.gov/publications/detail/fips/203/final. Accessed on: 13 Apr. 2025.
NVD. CVE-2021-44228 Detail. 2021. Disponível em: https://nvd.nist.gov/vuln/detail/CVE-2021-44228. Accessed on: 13 Apr. 2025.
OWASP. Secrets Management Cheat Sheet. 2023. Disponível em: https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html. Accessed on: 13 Apr. 2025.
RAHMAN, M. et al. Secrets in Source Code: Reducing False Positives using Machine Learning. In: ICSE, 2019. Disponível em: https://ieeexplore.ieee.org/document/8811951. Accessed on: 13 Apr. 2025.
SALTZER, J.; SCHROEDER, M. The Protection of Information in Computer Systems. Proceedings of the IEEE, 1975. Disponível em: https://ieeexplore.ieee.org/document/1451869. Accessed on: 13 Apr. 2025.
SHANNON, C. A Mathematical Theory of Communication. Bell System Technical Journal, 1948. Disponível em: https://ieeexplore.ieee.org/document/6773024. Accessed on: 13 Apr. 2025.
TRUFFLEHOG. TruffleHog Documentation. 2024. Disponível em: https://github.com/trufflesecurity/trufflehog. Accessed on: 13 Apr. 2025.