Kubernetes applications frequently handle sensitive information such as database passwords, API keys, authentication tokens, connection strings, encryption keys, and customer data.
These values are required for normal application operations, but they also create a security risk when an application crashes.
When a process generates a memory dump, it captures information about the process at a particular point in time. Depending on the dump type, this information may include application memory, thread states, object references, request data, and sensitive values that were loaded into memory.
For example, an ASP.NET Core application may read a database password from a Kubernetes Secret and use it to establish a database connection. Although the password is not written to application logs, it may still exist in the process memory.
If a full memory dump is generated during a crash, that password could become part of the dump file.
The risk does not end when the Pod terminates. Crash dumps may be copied to persistent volumes, diagnostic storage, centralized investigation systems, or external support environments. Anyone who obtains an unauthorized copy may gain access to information that was originally protected inside the application.
Preventing this requires more than protecting Kubernetes Secrets. Teams must also control dump generation, restrict diagnostic permissions, secure storage, and define how diagnostic files are retained and deleted.
Understand Why Crash Dumps Can Contain Secrets
A crash dump is a snapshot of a process that helps developers investigate application failures.
It can contain information such as:
Managed objects and their values.
Database connection information.
Authentication tokens.
HTTP request and response data.
Exception details and stack information.
Application configuration values.
Temporary buffers containing sensitive information.
Consider an ASP.NET Core service that retrieves a database connection string from an environment variable:
string connectionString =
Environment.GetEnvironmentVariable(
"DATABASE_CONNECTION_STRING")
?? throw new InvalidOperationException(
"Database connection string is missing.");
The application uses this value to connect to its database.
Even if the connection string is never written to a log, it can remain in process memory while the application is running.
Now consider an application configured to generate a full dump when it crashes. The dump may contain memory associated with the connection string and other sensitive objects.
This is why crash dumps must be treated as sensitive security artifacts rather than ordinary debugging files.
A Kubernetes Secret protects how sensitive values are stored and delivered through Kubernetes. It does not guarantee that those values will never appear in application memory or diagnostic output.
Understand the Different Types of .NET Dumps
.NET supports several dump types. The amount of information collected depends on the selected type.
The main types include:
Dump type | Description | Security consideration |
|---|
Mini | Contains module lists, thread lists, exception information, and stacks | May still expose sensitive values available through stack and diagnostic information |
Heap | Contains a large portion of process memory, including managed heap information | Can expose application objects and sensitive data |
Triage | A smaller dump that removes some personal information, such as paths and passwords | Should still be treated as sensitive |
Full | Contains the largest amount of process information, including module images and memory | Has the greatest potential exposure |
The dump type should be selected according to the diagnostic requirement.
For example, a full dump may help investigate complex memory corruption or runtime problems, but it also creates a larger security exposure.
A triage dump can reduce some personal information, but it should not be treated as completely sanitized.
The important point is that smaller dumps are not automatically safe dumps.
Disable Automatic .NET Crash Dump Collection When It Is Not Required
The .NET runtime supports environment variables for configuring automatic dump collection after a crash.
One important setting is:
DOTNET_DbgEnableMiniDump
When this variable is set to 1, the runtime enables automatic mini dump generation. Its default value is 0.
For production applications that do not require automatic crash dumps, explicitly configure it as disabled.
In a Kubernetes Deployment, this can be done through the container environment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
replicas: 3
selector:
matchLabels:
app: order-api
template:
metadata:
labels:
app: order-api
spec:
containers:
- name: order-api
image: mycompany/order-api:latest
env:
- name: DOTNET_DbgEnableMiniDump
value: "0"
- name: ASPNETCORE_ENVIRONMENT
value: "Production"
This prevents the .NET runtime's automatic crash-dump mechanism from being enabled through this setting.
It is important to understand that this controls .NET runtime dump generation. It does not disable every possible operating-system-level core dump mechanism.
If the application uses another diagnostic tool or an external crash collector, that mechanism needs to be reviewed separately.
Understand the Difference Between .NET Dumps and Linux Core Dumps
A common mistake is assuming that disabling .NET automatic dump collection prevents all memory dumps.
Linux has its own core dump mechanism.
When a process terminates because of certain signals, the operating system may generate a core file depending on the process resource limits and kernel configuration.
The relevant Linux setting is:
/proc/sys/kernel/core_pattern
This determines how core dumps are handled. Depending on the system configuration, the kernel may write a file or send the dump to a configured user-space handler.
Another important setting is the process core-file size limit, known as RLIMIT_CORE.
A process can inspect its current core-file limit using:
ulimit -c
A value of 0 means the process has a zero core-file size limit.
A startup script can set this limit before launching the application:
#!/bin/sh
ulimit -c 0
exec dotnet MyApplication.dll
The exec command replaces the shell with the .NET process while preserving the configured process limits.
However, this is only one layer of protection. Linux systems that send core dumps to a user-space handler through kernel.core_pattern may not enforce RLIMIT_CORE in the same way as ordinary core-file creation.
Therefore, cluster administrators should also review the node operating system's core-dump configuration and any configured collection service, such as systemd-coredump.
Kubernetes cannot configure every host-level kernel setting through a Pod specification. Node-level configuration must be managed by the cluster administrator.
Configure Kubernetes Container Security Settings
Disabling automatic dump collection is important, but the container should also follow a restrictive security configuration.
A production application generally does not need root privileges or unrestricted Linux capabilities.
Consider the following configuration:
apiVersion: apps/v1
kind: Deployment
metadata:
name: order-api
spec:
replicas: 2
selector:
matchLabels:
app: order-api
template:
metadata:
labels:
app: order-api
spec:
securityContext:
runAsNonRoot: true
runAsUser: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: order-api
image: mycompany/order-api:latest
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
env:
- name: DOTNET_DbgEnableMiniDump
value: "0"
This configuration introduces several security controls.
Setting | Purpose |
|---|
runAsNonRoot | Prevents the container from running as root |
runAsUser | Specifies the application user |
allowPrivilegeEscalation: false | Prevents privilege escalation through the container process |
readOnlyRootFilesystem | Prevents writes to the container root filesystem |
capabilities.drop: ALL | Removes unnecessary Linux capabilities |
seccompProfile: RuntimeDefault | Uses the container runtime's default seccomp profile |
These settings reduce the container's attack surface and make it harder for an application or compromised process to perform privileged operations.
However, they should not be described as a complete core-dump prevention mechanism. Host-level core-dump handling and runtime diagnostic configuration still need separate controls.
Also, if the application requires writable temporary storage, provide a dedicated writable volume rather than making the entire root filesystem writable.
Protect Diagnostic Tools and Collection Permissions
Some production teams need crash dumps to investigate serious application failures.
In these situations, completely disabling diagnostics may not be practical.
.NET provides tools such as dotnet-dump and dotnet-monitor for collecting and investigating application diagnostics.
However, collecting dumps requires additional permissions and access to process memory.
For example, on Linux containers, dump collection may require ptrace permissions. Depending on the environment and security policy, the collector may need specific capabilities and compatible seccomp settings.
Do not grant these permissions to every application container simply because developers may need diagnostics later.
A better design separates the application workload from the diagnostic collection process.
For example:
Keep the application container running with minimal permissions.
Run diagnostic collection through a controlled operational process.
Grant access only to authorized diagnostic operators.
Restrict which workloads can be inspected.
Record who requested and collected each dump.
Remove temporary permissions after the investigation.
This approach reduces the number of processes that can access application memory.
Store Crash Dumps Outside Ordinary Application Storage
If crash dumps are required, their storage location must be protected.
Avoid storing dumps in:
Publicly accessible object storage.
Shared application directories.
Unrestricted persistent volumes.
General-purpose file shares.
Container image layers.
Developer-accessible directories without appropriate controls.
Instead, use a dedicated diagnostic storage location with restricted access.
A secure storage design should include:
Encryption at rest.
Encryption during transfer.
Access restrictions based on operational roles.
Audit logging for uploads and downloads.
A defined retention period.
Secure deletion after the investigation.
Restrictions on downloading dumps to unmanaged devices.
A dump should not automatically be copied into a centralized logging system.
Logging platforms are designed for application events and operational visibility. Memory dumps are much larger and can contain far more sensitive information.
Treat them as a separate category of diagnostic data.
Avoid Exposing Secrets Through Application Logs
Crash dumps are only one possible source of secret exposure.
An application may accidentally expose credentials through exception messages, configuration logging, or request diagnostics.
For example, this is unsafe:
logger.LogInformation(
"Database connection: {ConnectionString}",
connectionString);
The connection string may contain a username and password.
A safer approach is to log only non-sensitive information:
logger.LogInformation(
"Database connection configuration loaded.");
When troubleshooting connection failures, log the server identifier or database name only if it is permitted by the application's security policy.
Avoid logging complete HTTP headers when they may contain Authorization or Cookie values.
Also review exception handling and telemetry configuration to ensure that sensitive request data is not automatically captured.
Reducing sensitive information in memory and logs does not eliminate every risk, but it reduces the amount of information that can be exposed through diagnostics.
Verify Crash Dump Protection in the Kubernetes Environment
A security configuration should be tested rather than assumed to work.
For a .NET application, inspect the configured environment variable:
kubectl exec deployment/order-api -- \
printenv DOTNET_DbgEnableMiniDump
The expected value is:
0
If the application image includes a shell and the process exposes its limits, inspect the process resource limits:
kubectl exec deployment/order-api -- sh -c \
'cat /proc/1/limits'
Look for the core-file size limit.
Also review the node operating system's core-dump configuration through the cluster administration process.
For example, cluster administrators can inspect:
sysctl kernel.core_pattern
The command should be executed on the relevant node, not assumed to be a Pod-level setting.
Test the actual production image and verify that:
Automatic .NET dump collection is disabled when not required.
The container does not have unnecessary diagnostic capabilities.
The node's core-dump handling follows the intended security policy.
No unexpected dump files are written to shared storage.
Diagnostic collection is available only through approved procedures.
Logs do not expose connection strings, tokens, or credentials.
Do not test crash behavior by terminating production workloads without an approved maintenance or testing procedure.
Common Mistakes to Avoid
Mistake | Why it creates problems | Better approach |
|---|
Assuming Kubernetes Secrets protect process memory | Secrets can still exist in application memory | Protect diagnostic output separately |
Disabling only .NET automatic dump collection | Linux or external diagnostic tools may still create dumps | Review every dump-generation mechanism |
Assuming a triage dump contains no sensitive information | Some personal information is removed, but other sensitive data may remain | Treat every dump as confidential |
Running diagnostic tools with unrestricted privileges | Increases access to application memory | Use controlled diagnostic permissions |
Storing dumps in ordinary application storage | Other workloads or users may access them | Use dedicated restricted storage |
Assuming readOnlyRootFilesystem disables core dumps | Core collection may be handled outside the container filesystem | Configure process and node-level policies |
Keeping dumps indefinitely | Increases the impact of unauthorized access | Define retention and deletion policies |
Best Practices for Production Applications
Explicitly disable automatic .NET crash dump collection when it is not required.
Review Linux core-dump settings on every Kubernetes worker node that runs sensitive workloads.
Use non-root containers with minimal Linux capabilities.
Apply the RuntimeDefault seccomp profile unless a documented requirement justifies another policy.
Avoid mounting shared writable volumes for diagnostic files.
Use Kubernetes Secrets or an external secret-management system for credential delivery, but do not assume this protects secrets already loaded into process memory.
Restrict dump collection to authorized operators and dedicated diagnostic workflows.
Encrypt diagnostic artifacts and restrict access to their storage locations.
Define a retention period and securely remove dumps when they are no longer needed.
Review application logs and telemetry for accidental exposure of credentials and sensitive request information.
Test dump-generation controls using the same container image, runtime, and node configuration used in production.
Summary
Crash dumps are valuable for investigating application failures, but they can also expose sensitive information stored in process memory.
In Kubernetes environments, protecting secrets requires more than securing Kubernetes Secret objects. Developers must understand the difference between .NET runtime dumps and Linux core dumps, disable unnecessary automatic collection, and review the configuration of the underlying worker nodes.
Container security settings, restricted diagnostic permissions, encrypted storage, and controlled retention provide additional protection when dumps are genuinely required.
The most important principle is to treat every memory dump as potentially sensitive. Collect only what is necessary, store it securely, restrict who can access it, and remove it when the investigation is complete.
Join the conversation! Your thoughts help the community grow.