Chapter 23Lesson 03180–240 min

Secrets, Credentials, Environment Isolation, and Security Hygiene: Configuration, Design Patterns, and Trade-Offs

Choose secret sources, identity boundaries, redaction controls, packaging, and evidence policies based on the state each choice actually affects.

Design trade-offsCI secret storesLeast privilegeRedaction ≠ encryptionPortability

Learning objectives

  • Choose between Secret and plaintext variables based on disclosure risk and consumer support.
  • Compare environment, CLI, variable files, and CI/external stores as source channels.
  • Separate Robot redaction from transport encryption and access control.
  • Design per-environment identities and parallel-worker isolation.
  • Use a decision table to justify a security architecture from observable runtime behavior.

Current compatibility baseline — verified 2026-08-31. Robot Framework 7.4.2 is the stable course baseline and requires Python 3.8+. Secret variables and robot.api.types.Secret are new in Robot Framework 7.4. Secret values are masked in Robot's own argument/return representations, but they are not encrypted, and code can access the real value through .value. The mandatory labs use only a deliberately fake value, a synthetic allowlisted target, local files under an isolated temporary/project directory, and Robot Framework core/standard libraries. No real account, browser, API, database, SSH service, Pabot, CI provider, container runtime, secret manager, paid platform, or production system is required. Robot Framework 7.5b1 is prerelease and is not required.

1. Security choices are state-placement choices

The question is not “Which syntax hides the password?” It is “Where does the value exist, who can read it, what receives it, what records it, and how long is each copy retained?” Use the smallest surface that still supports the operation.

Choice Prefer when Trade-off / state affected
Secret wrapper Robot/library can preserve the object until the exact consumer boundary. Reduces Robot log exposure; does not constrain consumer code or memory access.
Plaintext variable Only for non-sensitive configuration. Simpler but fully loggable; inappropriate for credentials.
Environment variable source Local labs and CI injection where process inheritance is controlled. Avoids source commit; can leak to child processes/dumps.
CLI literal Non-secret values. Easy to reproduce; secret literals can persist in history/process listings/logs.
Committed variable file Public/non-secret configuration. Versioned and reviewable; wrong place for live credentials.
CI/external secret store Production automation. Adds platform dependency but improves policy, rotation, auditing and access scope.

2. Secret wrapper versus plaintext

Secret is useful when the caller and callee can carry the object without converting it to a normal string. A typed Python keyword can require Secret, making accidental literal input fail conversion. But if a third-party library accepts only str, some adapter eventually has to unwrap .value. That adapter becomes a high-sensitivity boundary and should be small, reviewed, and quiet.

from robot.api.types import Secret

def send_with_client(token: Secret, client):
    # Keep this boundary tiny. Configure the client so it does not dump auth data.
    return client.send(token.value)

3. Environment variable versus CLI literal versus secret store

Environment variables are not intrinsically secret. They are merely a delivery channel. They may be inherited by child processes, exposed by diagnostics, or retained by a CI agent. Their main local advantage is that the secret need not appear in the Robot file or command text.

A CI secret store is better for production because it can provide access control, masking, audit events, and environment-specific values. Robot Framework should consume the injected value, not reinvent the store.

4. Redaction versus encryption versus authorization

Control Question answered Robot Secret provides it?
Redaction / masking Should this representation show the raw value? Yes, for Robot-controlled Secret representations.
Encryption at rest Can storage readers recover plaintext without a key? No.
Encryption in transit Can network observers read the credential? No; transport/client responsibility.
Authorization Is this identity allowed to perform the operation? No; target/platform responsibility.
Least privilege How much damage can the identity do? No; identity/policy design.
Rotation/revocation How is a compromised value replaced or invalidated? No; secret/identity system responsibility.

5. Local .env convenience versus repository hygiene

Robot Framework core does not magically load .env files. A team may use an external loader, shell script, IDE setting, or custom variable file, but the file becomes a plaintext secret store unless protected. If a local .env convention is used, commit a .env.example containing names only, ignore the real file, and add repository secret scanning. Do not teach “add to .gitignore” as sufficient after a value has already been committed—the Git history still contains it.

6. Per-environment identity versus shared account

Use distinct identities for development, staging, and production, and narrow permissions to the required operations. Parallel workers should not share one mutable credential if independent credentials or scoped tokens are available. Identity separation improves attribution and prevents one worker's cleanup or lockout from contaminating another.

Pattern Maintainability Security Parallel/CI
Shared admin account Low setup effort, high hidden coupling Largest blast radius; poor attribution Contention and lockout risk.
Per-environment account Clear environment ownership Smaller blast radius Good default for CI environments.
Per-run short-lived identity More integration work Best revocation/attribution when platform supports it Strong isolation; excellent for parallel ephemeral runners.

7. In-process Secret use versus downstream logs

Robot cannot redact bytes it never controls. Browser screenshots, HAR files, HTTP debug dumps, SSH traces, database audit logs, shell set -x, and application logs may record sensitive data. For every external library, document what it logs at each verbosity level, and make sensitive debugging opt-in with synthetic credentials.

Never “solve” a disclosure problem by disabling TLS or SSH verification. Verification and secrecy are complementary controls; removing authenticity makes credential theft easier.

8. Worked decision: CI service-level check

Requirement Decision Why
Token supplied by CI CI secret store → environment injection No literal in repository or normal command text; platform owns policy.
Robot variable ${TOKEN: Secret} from environment Robot keeps normal argument/return representation masked.
HTTP client Small adapter unwraps only at request call Contains the high-sensitivity boundary.
Evidence Status, correlation ID, target ID; no header/body dumps Diagnosable without credential copies.
Identity Staging-only least-privilege token Wrong-target damage is limited.
Parallelism Distinct test records; token policy documented Avoids mutable state collision; Chapter 24 will add worker-level controls.

9. Keep configuration layers separate

Layer Examples Do not confuse with
Robot core Secret variable syntax, output/log levels, variable scope CI credential store.
Python environment Robot version, dependency pins Target authorization.
External library HTTP/browser/database trace configuration Robot Secret masking.
SUT Accounts, permissions, test tenants Robot library scope.
RobotCode/editor Local interpreter and lint assistance Runtime secret source.
CI provider Secret injection, runner isolation, artifacts Robot execution engine.
Container/cloud Runtime identity, mounts, workload credentials Robot variables.

10. Summary and bridge

A secure design minimizes the number of places that ever hold plaintext, uses Secret where Robot can preserve the boundary, configures downstream clients not to disclose, isolates identity by environment/run, and governs artifacts independently. Lesson 4 applies that model to realistic failures and shows how to diagnose a suspected leak without destroying the evidence.

Knowledge check

Is an environment variable a secret manager?

Why can a committed variable file remain a problem after deleting the line?

What is the smallest safe boundary when a third-party client requires plaintext?

Why prefer per-environment identities?

Next lesson

Secrets, Credentials, Environment Isolation, and Security Hygiene: Diagnostics, Failure Modes, and Production Practices

Continue with Secrets, Credentials, Environment Isolation, and Security Hygiene: Diagnostics, Failure Modes, and Production Practices. It builds directly on the state, evidence, and operating assumptions established here, so carry those constraints forward rather than treating the next page as an isolated topic.

References and version anchors

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0 Send only Ethereum/ERC-20 compatible assets to this address.