# Ensure no duplicate UIDs exist

Necessity: Each user account on a system should have a unique User ID (UID). Duplicate UIDs create a critical security vulnerability by making user identity ambiguous to the operating system. When two or more users share the same UID, they are treated as the same user regarding file permissions and process ownership. This can lead to unauthorized access to files and data, as the system cannot distinguish which user is performing an action. It breaks the principle of non-repudiation, as actions cannot be reliably audited or traced to a specific individual, and undermines access control policies.

Auditing and Remediation: The audit script checks the `/etc/passwd` file to identify and count any UIDs that have been assigned to multiple user accounts. The remediation script is designed to report these findings rather than perform automated changes. Automatically altering a user's UID is a complex and risky operation that can sever the user's ownership of their home directory and other files across the system. Therefore, the script logs the conflicting accounts for a system administrator to resolve manually, ensuring that ownership is correctly reassigned and system integrity is maintained.

Recommended State Rationale: The recommended state for all security levels (Basic, Moderate, and Strict) is `0` duplicate UIDs. There is no acceptable scenario for having duplicate UIDs in a secure environment. This is a fundamental principle of user account management. The presence of even a single duplicate UID represents a significant misconfiguration and security flaw. Therefore, the only compliant and secure state is to have zero duplicates.

## Recommended State Configuration

| Security Level | Value |
|----------------|-------|
| **Basic** | `[0, 0]` |
| **Moderate** | `[0, 0]` |
| **Strict** | `[0, 0]` |
| **Type** | `RANGE` |

## Audit Script Working

Bash script that counts the number of user IDs (UIDs) that are assigned to more than one user account. The script must parse the `/etc/passwd` file, identify any UIDs that appear more than once, and return a single integer representing the total count of such duplicate UIDs. The output must be only the number, with no additional text or formatting.

## Remediation Script Working

Bash script that takes a single positional command-line argument, which should be the desired number of duplicate UIDs (always '0' for this control). Since automatic remediation is not recommended due to its potential to disrupt user access and file ownership, the script should not modify any accounts. Instead, it must identify all user accounts sharing a UID and log the findings for manual administrator review. If the number of duplicate UIDs found is equal to the provided argument ('0'), the script will return `true`. Otherwise, it will log the details and return `false`.

