> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
