Skip to content

pycapnp aborts if loading schema file that is visible but not readable #391

Description

@theunkn0wn1

IF pycapnp is asked to load a schema file that it can see (user has at least +r on the directory) but the schema file itself is not readable (user does not have read permission), pycapnp crashes with an bort.

Steps to reproduce:

  • write a schema file as user A, e.g. root. ( it does not need to be root, I encountered this without root)
  • set file permissions on the schema file to be restrictive, e.g. 0600
  • set file permissions on the directory containing the file to be lax e.g. 0.644
  • spawn python as user B e.g. nonroot
  • attempt to load the schema file as the python process running under user B
/foo/bar # ls -l
total 4
-rw-r-----    1 root     root           633 Jan  7 02:45 addressbook.capnp
/foo/bar # su nonroot
/foo/bar $ python3
Python 3.12.5 (tags/v3.12.5-2-gcf84421-dirty:cf84421, Aug 26 2024, 13:24:52) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import capnp
>>> capnp.load("addressbook.capnp")
terminate called after throwing an instance of 'kj::ExceptionImpl'
  what():  kj/filesystem-disk-unix.c++:771: failed: openat(fd, path, O_RDONLY): Permission denied; path = foo/bar/addressbook.capnp
stack: 7081941c383d 7081941c39ac 7081941b4dcf 708194014c20 70819401576b 708193ffb243 708193ff85fa 708193fb9813 708194d60d07 708194d4a4da 708194dd3069 708194df88f9 708194df30ed 708194d2bd28 708194d2bf11 708194c9c78e 708194d2c0ee 708194c97eec 708194dbb287 70819498b187 70819498b24a 643c60afa074
Aborted (core dumped)
/foo/bar $ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions