Repository navigation
Description
Summary
The ABS-compatible API ignores Silo's per-user download privilege
(users.download_allowed / models.User.DownloadAllowed). Users with downloads
disabled can both see download UI in Audiobookshelf clients and successfully
download complete audiobook files through the compat listener.
The native download path enforces this correctly
(internal/download/service.go returns ErrDownloadNotAllowed); the ABS layer
simply never wired the check in.
Steps to reproduce
- Create a non-admin user and disable downloads (
download_allowed = false). - Connect to the ABS listener (
:13378) with the official Audiobookshelf app
and log in as that user. - Download succeeds. Equivalently, a direct authenticated request works:
GET /api/items/{libraryItemId}/file/{ino}/download.
Expected: download UI hidden and the request rejected with 403.
Actual: file is served.
Root cause (two independent gaps)
-
No server-side enforcement.
handleFileStream
(internal/audiobooks/abs/file_handler.go) backs both
GET /api/items/{libraryItemId}/file/{ino}and the/downloadvariant.
It checks authentication (absAuthFrom) and library access
(accessFilterForAuth), then serves the file —DownloadAllowedis never
consulted. -
Login payload advertises the permission. The ABS login response
(internal/audiobooks/abs/login.go,permissionsblock) hardcodes
"download": truefor every user, so client apps render download UI
unconditionally. (update/delete/upload/accessExplicitContent
are also hardcodedtrue— lower stakes today since the compat layer
doesn't implement those mutations, but same pattern.)
Why the fix is safe for playback
ABS playback does not stream through the file route: handlePlayStart
issues short-lived session-scoped track URLs
(/abs/public/session/{sid}/track/{idx}, see play_response.go). The
/file/{ino} routes are purely the offline-download/save surface, so both
variants can be hard-gated on DownloadAllowed without affecting streaming
for restricted users.
Suggested fix
- In
handleFileStream: load the authenticated user and return403when
!user.DownloadAllowed, for both the bare and/downloadvariants. - In the login response (and
/api/meif it echoes a permissions object):
report the real value,"download": user.DownloadAllowed, so compliant
clients hide the download UI. - Consider deriving the other hardcoded permission flags from real state while
in there, or leaving a comment explaining why they remaintrue.
Notes
- Native download service (
internal/download/service.go) is the reference
behavior:checkEnabled+if !user.DownloadAllowed → ErrDownloadNotAllowed. - Worth a follow-up sweep: RSS feed file routes (
/feed/{slug}/file/{ino}) are
public by design (podcast semantics) — confirm feed creation is the
intended gate for restricted users.
Activity
fix(audiobooks): enforce download privilege on ABS file routes (#141)
Tobechukwu-Njoku commentedon Aug 24, 2026
Still reproducible on
mainat820eef77— and there's some history here worth surfacing before anyone writes this again.The gap is unchanged
internal/audiobooks/abs/contains no reference toDownloadAllowed/download_allowedat all. The three surfaces that serve raw bytes or advertise the capability are all unguarded:file_handler.go—handleFileStream(:55) checks auth (:57) and library access viaaccessFilterForAuth, but nothing consults the download privilege.rss_feeds_handler.go— same.login.go:267— still emits"download": trueunconditionally, so ABS clients render the offline-save UI regardless of the account's privilege.The native path meanwhile enforces at
internal/downloads/policy.go:176and:204, throughpolicyengine.ActionDownload.There was already a fix, and it was withdrawn
#234 ("fix(audiobooks): enforce download privilege on ABS-compat download routes") covered exactly these three surfaces via a narrow
abs.DownloadPolicydependency. @Quick104 opened it 2026-06-26 and closed it 2026-07-01 without comment.The dates are suggestive: #282 ("access groups + embedded OPA policy engine with decision audit log",
42602b78) merged 2026-07-05, four days later. That refactor introducedinternal/policy, whoseinput.go:4-5reads:"or serve" describes this case exactly. So my read is that #234 wasn't wrong so much as overtaken — a bespoke adapter threaded through the ABS handler stopped being the right shape once a general policy engine existed. That is inference on my part, not something I can see stated anywhere, so please correct it if the reason was different.
Either way the ABS layer never got wired into the new engine, so the hole outlived the refactor.
What I'd like to know before doing anything
Which enforcement point do you want?
policyengine.ActionDownloadthe wayinternal/downloadsdoes, so one policy governs both stacks and the decision lands in the audit log.handleFileStreamalready hasa.UserIDin hand, so the identity is available.abs.DownloadPolicydependency, if there's a reason the compat layer should stay decoupled from the policy engine.Happy to implement whichever you prefer, including the
login.gocapability flag so clients stop advertising downloads to accounts that can't use them. I held off writing it because this is an authorization behavior change and CONTRIBUTING asks to coordinate those first — and because the last attempt was withdrawn for reasons I'd rather understand than re-derive.