cloudflare / cloudflare/cloudflare-docs

Kandji Audit and Enforce Script (docs) — integer version comparison causes reinstall loops

Open
#31,940 1 comment 0 reactions 5 assignees Claimed by @lpraneis View on GitHub
content:edit documentation product:cloudflare-one stale
Dominant language
MDX
Stars
5.2k
Forks
16.7k
Avg merge
2d 6h
Merged PRs (30d)
337

Description

### Existing documentation URL(s)

https://developers.cloudflare.com/cloudflare-one/team-and-resources/devices/cloudflare-one-client/deployment/mdm-deployment/partners/kandji/ (section: Audit and Enforce Script)

### What changes are you suggesting?

Review the version comparison logic in the Audit and Enforce Script on the Kandji deployment page (https://developers.cloudflare.com/cloudflare-one/team-and-resources/devices/cloudflare-one-client/deployment/mdm-deployment/partners/kandji/). The script currently strips the dots from both version strings and compares them as integers:

`installed_version="$(return_installed_app_version $APP_NAME | /usr/bin/sed 's/\.//g')"
enforced_version="$(echo $ENFORCED_VERSION | /usr/bin/sed 's/\.//g')"
if [ "$installed_version" -lt "$enforced_version" ]; then`

Collapsing a dotted version into a single integer loses positional meaning, so versions that reduce to a different number of digits compare incorrectly. Replace this with a real version comparison (for example using sort -V ordering, or a per-field numeric comparison of the dotted segments) so version segments of differing lengths are compared correctly. Since the script carries a Kandji Solutions Engineering copyright, the corrected version likely needs to be coordinated with Kandji.

**Why should the docs be changed? What use cases does it support?**

The published script produces false negatives whenever the installed version has fewer total digits than the enforced version. Real example from a support case: installed 2026.6.822.0 becomes 202668220 (9 digits) and enforced 2026.4.1350.0 becomes 2026413500 (10 digits), so 202668220 -lt 2026413500 evaluates true, and the audit reports the newer installed client as older than the enforced minimum. This affects any admin who copies the documented script and enforces a minimum version whose stripped form has a different digit count than the installed version — a common scenario as client version numbers grow. In the reported case, on every ~15-minute Kandji agent check-in the audit failed and Kandji reinstalled the package; the package scripts restarted the WARP daemon each time, causing recurring connectivity drops across roughly 22–29 of 84 devices.

**What is the expected outcome?**

The audit script correctly determines whether the installed client meets or exceeds the enforced minimum version, regardless of segment length, and only triggers a reinstallation when the installed version is genuinely older. Admins following the docs no longer experience reinstall loops or the resulting WARP daemon restarts and connectivity interruptions.

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.