> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/iam/appsec2-docker-17.md).

# 'chpasswd' is used to set or remove passwords misconfiguration detected in code

## Rule Details

|                        |                                            |
| ---------------------- | ------------------------------------------ |
| Cortex AppSec Rule ID  | APPSEC2\_DOCKER\_17                        |
| Category - Subcategory | Public Exposure - Encryption And Protocols |
| Provider               | OTHER                                      |
| Severity               | MEDIUM                                     |
| Framework              | DOCKER                                     |

## Impact

This rule is looking for instances where 'chpasswd' is used in dockerfiles. 'chpasswd' is a command that changes the password of a user in Linux OS. Insecure usage of this command can lead to potential security risks. Usually, this command is used to set or remove passwords in Docker containers.

If attackers gain access to these containers, they could easily change passwords, escalate their privileges, or gain unauthorized access to sensitive information. Consequently, this could lead to system compromise or data breach. Therefore, it's crucial to avoid using 'chpasswd' in Docker containers to maintain secure environments.

## How to Fix

*Resource:* Dockerfile

* *Arguments:* RUN

To fix this issue, do not use the `chpasswd` command to set or remove passwords in your Docker scripts. You should use other secure methods to handle authentication in your Docker containers as 'chpasswd' can expose sensitive data and it's not considered a secure practice.

## In the fixed code, we're using `adduser --disabled-password` which is a more secure way to add a user without a password. For instance, Docker might handle interaction with your application, this way you ensure the Docker container is running with the proper permissions, reducing the risk of a potential breach. It's a more secure practice as it avoids hardcoding the password in the Dockerfile. This method doesn't expose sensitive data, thus following the best security practice. \[source,go]

## RUN adduser --disabled-password --gecos "" user


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/iam/appsec2-docker-17.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
