Root CauseWhat broke, why, and the fix.

AppleDouble files ran before every WordPress response

· wordpress, deployment, debugging
ⓘ Operated by TechAthletes. Every post here is a bug we hit in our own work — symptom, root cause, fix. Nothing is sponsored and we are not paid to mention any tool.

What we hit

We moved a WordPress mu-plugin to Xserver during the HP switch for tech-athletes.com. The transfer used a tar stream:

tar czf - ... | ssh ... 'tar xzf -'

After that upload, output we did not expect appeared at the start of requests across the multisite. The visible problem was not in the PHP file we meant to deploy. It came from a companion file that macOS tar included with it.

The file was named:

._techathletes-hp.php

That name mattered because the file sat directly under wp-content/mu-plugins/. WordPress loads wp-content/mu-plugins/*.php without caring about the intended role of each file. The AppleDouble file also ended in .php, so WordPress treated it as something to load.

The file was a 163 byte binary file created from the com.apple.provenance extended attribute. WordPress did not know that it was metadata from macOS. It only saw a PHP-looking filename in the mu-plugins directory. The result was binary bytes emitted at the beginning of every request handled by the multisite.

This was not limited to browser responses. The same output also mixed into wp command output. That made a separate automation step make the wrong decision: $(wp post list ...) returned a garbage string, so the script judged that a fixed page already existed and skipped creating it. That skipped page creation was how we noticed the problem.

What we observed

The first useful observation was the beginning of the public HTML. We checked the front of the response with od -c:

curl -s https://<site>/ | od -c | head

After removing the unwanted bytes, the response began with:

<!DOCTYPE

That gave us a direct before-and-after check on the symptom. The broken response had bytes before the document start. The corrected response started where HTML should start.

The second observation was about cache contamination. We did not want to remove the source file and leave bad cached pages behind. The note records a targeted check against wp-super-cache: files written after 23:49 were searched for com.apple.provenance.

com.apple.provenance

That check covered 25 files and found 0 matches. The reason recorded in the incident was that the bytes were emitted before output buffering began, so they did not enter the cached body.

The command-line symptom was also important. The wp command did not merely fail in a clean way. Its output was polluted. A command substitution that was meant to answer “did this page already exist?” received garbage text and treated the result as non-empty. That turned corrupted output into a false “already exists” result.

These observations kept the investigation concrete. We had unexpected bytes at the beginning of output, a .php file under mu-plugins that was not meant to be PHP code, and command output that became unsafe to use as a simple empty-or-not-empty signal.

Why it happened

The root cause was the boundary between macOS file metadata and a WordPress directory that executes every PHP-looking file inside it.

On macOS, tar included an AppleDouble file for the extended attribute com.apple.provenance. AppleDouble is a standard format, specified in RFC 1740, that stores a file's Macintosh-specific metadata separately from its data fork so the metadata survives on filesystems that do not support it natively. The upload therefore did not contain only the mu-plugin we meant to deploy. It also contained ._techathletes-hp.php.

That filename is harmless only in places where it is treated as metadata or ignored as an ordinary dot-underscore file. The mu-plugins directory is not such a place. WordPress reads wp-content/mu-plugins/*.php by filename pattern. The AppleDouble file matched the pattern, so it entered the load path.

Once loaded, the 163 byte binary file was output at the start of every request for the multisite. The impact reached 48 sites because this was a multisite mu-plugin location. The same early output also appeared in wp command output, which made later shell logic unsafe.

The deploy command looked like a normal way to move files. The problem was not that tar failed to transfer the file. It transferred too much for this destination. A directory that reads all matching files changes the risk of hidden companion files.

The shell check had its own lesson. A command substitution was treated as a truthy or falsey presence check. When the command output acquired unrelated bytes, the check did not know the difference between a valid existing ID and garbage. It fell toward “present,” and page creation was skipped.

How we fixed it

The deployed fix was added to website/hp/deploy.sh. It has checks on both sides of the transfer.

On the sending side, the deploy disables macOS copyfile behavior and tells tar not to include extended attributes:

export COPYFILE_DISABLE=1
tar --no-xattrs

That prevents the AppleDouble file from being bundled into the tar stream in the first place.

On the receiving side, the deploy removes dot-underscore files immediately after extraction:

find . -name '._*' -delete

That second step is there because a local setting can change. If the sender ever includes such a file again, the server-side cleanup still catches it before WordPress can load it.

The upload also compares md5 values between the local file and the uploaded file. The incident note does not record the exact command for that comparison, so we should not invent one here. The important part is the verification goal: after upload, compare the content that should exist on the server with the local source that was intended to be deployed.

The cache check was part of confirming the fix. Public HTML started with <!DOCTYPE after removal, and wp-super-cache did not contain cached bodies with com.apple.provenance among the checked files.

The shell logic needs the same kind of narrowing. When the expected value is an ID, the result should be checked as a number rather than only checked for being non-empty. The incident note states that command substitution can fail open in the wrong direction when garbage is mixed in. An empty-or-not-empty test is too broad for that job.

What we learned

The durable lesson is that deploy tooling has to match the behavior of the destination directory. mu-plugins, conf.d, cron.d, and *.d/ style directories all have the same general shape: they read a directory as configuration or code. Sending files from macOS into such directories means ._* files should be expected unless the transfer is configured to exclude them.

It is better to block the same failure on both sides. The sender should avoid packaging AppleDouble files, and the receiver should delete them before the application sees them. That is not duplication for its own sake. It protects against a future change in the local environment while keeping the server-side rule close to the dangerous directory.

We also learned to be careful with command output used as control flow. The wp command output was not trustworthy simply because it was non-empty. Once unexpected bytes entered stdout, a presence check became a false existence check. For an ID, “is numeric” is a narrower and safer question than “is there anything here.”

This incident was small in mechanism and broad in effect. A 163 byte AppleDouble file was enough to affect the first bytes of every request in a 48 site multisite because it landed in a directory where names are behavior. The fix was to make the deploy stop carrying macOS metadata, remove any dot-underscore files after extraction, and verify that the server received the file we meant to send.

All posts →

Get new posts by email

We email you only when a new post goes up here. You can unsubscribe at any time.

Privacy policy