Skip to content

Fix missing return in WebdavServlet doDelete after precondition failure#982

Merged
rmaucher merged 1 commit intoapache:mainfrom
Seth0x41:fix/webdav-doDelete-missing-return
Apr 7, 2026
Merged

Fix missing return in WebdavServlet doDelete after precondition failure#982
rmaucher merged 1 commit intoapache:mainfrom
Seth0x41:fix/webdav-doDelete-missing-return

Conversation

@Seth0x41
Copy link
Copy Markdown
Contributor

@Seth0x41 Seth0x41 commented Apr 6, 2026

When a WebDAV DELETE request includes a conditional header like If-Unmodified-Since or If-Match, and the condition fails, the server correctly responds with HTTP 412 Precondition Failed. However, it still proceeds to delete the resource because doDelete() is missing a return statement after setting the 412 status. The doPut() method handles this correctly by returning immediately.

This means conditional headers are not enforced for DELETE operations. A file can be deleted by any client regardless of the precondition check result.

POC

# 1. Create a file
curl -X PUT -d "protected content" http://localhost:8080/webdav/test.txt

# 2. DELETE with a precondition that should fail (date in the past)
curl -v -X DELETE -H "If-Unmodified-Since: Mon, 01 Jan 2001 00:00:00 GMT" http://localhost:8080/webdav/test.txt
# Returns 412 Precondition Failed

# 3. Check if file still exists
curl -v http://localhost:8080/webdav/test.txt
# Returns 404. File was deleted anyway despite the 412!

The fix adds the missing return after setting the 412 status, consistent with how doPut() already handles this case.

@Seth0x41 Seth0x41 force-pushed the fix/webdav-doDelete-missing-return branch from a2a27c0 to d8e506f Compare April 6, 2026 20:45
@rmaucher rmaucher merged commit 8cf9a07 into apache:main Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants