BetaOSM is in beta. Read its known limitations.
OSM

Our code

Six pieces of OSM's real code, unchanged, as it runs on your server. All of OSM is written this way.

An update needs enough signatures

Your server installs an update only when enough of OSM's keys signed it, each key counted once.

def verify(raw, keys, threshold, namespace, ssh_keygen='ssh-keygen'):
    """A signed envelope -> its payload bytes, when at least `threshold` distinct keys of `keys` signed them."""
    payload, sigs = envelope(raw)
    keys = key_set(keys)
    if not isinstance(threshold, int) or isinstance(threshold, bool) or threshold < 1:
        raise ChannelError('The signature threshold is not valid.')
    good = set()
    for fp, sig in sigs:
        if fp in keys and fp not in good and ssh_verify(keys[fp], namespace, payload, sig, ssh_keygen):
            good.add(fp)
    if len(good) < threshold:
        raise ChannelError(f'A signed file has {len(good)} valid signature{"" if len(good) == 1 else "s"} of the '
                           f'{threshold} needed ({namespace}).')
    return payload
src/osm/channel.py, line 162: verify

Never older, never out of date

An update list that is older than the last one, or out of date, is refused: nobody can hold your server on an old version.

def _fresh(d, what, now, longest):
    issued, expires = _int(d, 'issued', what), _int(d, 'expires', what)
    if issued > now + DAY:
        raise ChannelError(f'{what} was made in the future: is this server\'s clock right?')
    if expires <= now:
        raise ChannelError(f'{what} ran out on {time.strftime("%Y-%m-%d", time.gmtime(expires))}.')
    if expires - issued > longest:
        raise ChannelError(f'{what} is valid for too long.')


def _not_older(d, payload, stored, field, what):
    if stored is None:
        return
    old = _object(stored, d['type'])
    if d[field] < old[field]:
        raise ChannelError(f'{what} is older than the one this server has seen ({field} {d[field]} < {old[field]}).')
    if d[field] == old[field] and payload != stored:
        raise ChannelError(f'{what} has the {field} of the one this server has, but other contents.')
src/osm/channel.py, line 203: _fresh, _not_older

A second step that cannot be read is not "off"

When the file of an account's two-step sign-in cannot be read, OSM refuses the sign-in. The password alone never gets in by accident.

def read_two_step(user, path=None):
    """(Auth.totp_get; without the agent at hand: the Security check) An account's two-step sign-in, read from its file
    -> its record; None when it has none, or the file is another account's (other_account).  A file that is there but
    cannot be read, or is not one OSM wrote: OpError 503, never "none"."""
    try:
        with open(path or os.path.join(paths.TOTP_DIR, user + '.json'), encoding='utf-8') as f:
            d = json.load(f)
    except FileNotFoundError:
        return None
    except (OSError, ValueError) as e:                  # (ValueError: bad JSON, or bytes that are not UTF-8)
        _log_unreadable(user, getattr(e, 'strerror', None) or 'not valid JSON')
        raise OpError(_TOTP_UNREADABLE.format(user=user), 503)
    if not isinstance(d, dict) or not isinstance(d.get('enabled', False), bool) \
            or (d.get('enabled') and not (isinstance(d.get('secret'), str) and d['secret'])):
        _log_unreadable(user, 'not a two-step sign-in OSM wrote')
        raise OpError(_TOTP_UNREADABLE.format(user=user), 503)
    return None if other_account(d, user) else d
src/osm/agent/auth.py, line 190: read_two_step

From the Internet, a password is never enough

Through OSM Connect, every account needs its second factor.

def may_sign_in(user, second_factor):
    """(auth, once the password or the passkey was right) Connect's rules for the account: one it lets in (who: the
    Administrators, plus the chosen groups, or every account), with a second factor.  OpError(403) otherwise."""
    from . import passkeys
    if not _who_allows(user, load()['rules']):
        raise OpError('This account may not sign in through OSM Connect. An Administrator can allow it on the server\'s '
                      'own network (Settings > Remote access).', 403)
    if not second_factor:
        rp = connect_rp()
        if any(k.get('rp_id') == rp for k in passkeys.keys_of(user)):
            raise OpError('Through OSM Connect a password alone is not enough: sign in with your passkey.', 403)
        raise OpError('Through OSM Connect an account needs two-step sign-in. Set it up on the server\'s own network '
                      '(My Account > Security), then sign in here with its code.', 403)
src/osm/agent/ops_connect.py, line 2022: may_sign_in

A file's name is taken in one step

Moving a file never replaces one that someone else saved there a moment before.

def rename_noreplace(src, dst):
    """os.rename that never replaces what is at dst: FileExistsError then.  A check before a rename let a file made
    meanwhile (over SMB, by an app) be replaced without a word (the review of 10 Nov 2026).  Linux's renameat2 with
    RENAME_NOREPLACE; where the file system refuses that flag, a file is linked to dst and its old name removed (a link
    never replaces), and a folder is renamed onto an empty folder made for it (a rename never replaces one that is not
    empty); on one without links either, the check and the rename together, as before."""
    f = _libc_renameat2()
    if f:
        import ctypes
        if f(_AT_FDCWD, os.fsencode(src), _AT_FDCWD, os.fsencode(dst), RENAME_NOREPLACE) == 0:
            return
        e = ctypes.get_errno()
        if e not in (errno.EINVAL, errno.ENOSYS):
            raise OSError(e, os.strerror(e), src, None, dst)
    if os.path.isdir(src) and not os.path.islink(src):
        os.mkdir(dst, 0o700)                         # (FileExistsError when something is there)
        try:
            os.rename(src, dst)
        except OSError:
            try:
                os.rmdir(dst)
            except OSError:
                pass
            raise
        return
    try:
        os.link(src, dst, follow_symlinks=False)     # (FileExistsError when something is there)
    except FileExistsError:
        raise
    except OSError as e:
        if e.errno not in (errno.EPERM, errno.EOPNOTSUPP, errno.ENOTSUP, errno.EMLINK, errno.ENOSYS):
            raise
        if os.path.lexists(dst):                     # (no links on this file system: FAT, exFAT)
            raise FileExistsError(errno.EEXIST, os.strerror(errno.EEXIST), dst)
        os.rename(src, dst)
        return
    try:
        os.unlink(src)
    except OSError:
        os.unlink(dst)                               # (its old name could not go: as it was)
        raise
src/osm/helpers/fileops.py, line 1686: rename_noreplace

A bug becomes a test

When we fix a bug, a test makes the exact moment it happened, and stays.

def test_a_file_made_meanwhile_is_never_replaced(self):
    """The other client's file is made at the very moment between op_transfer's look at the name and the move."""
    for op, real in (('move', fo._move), ('copy', fo._copy)):
        with self.subTest(op=op):
            src = self.put('in/report.docx', 'mine')

            def theirs_first(p, d, job=None, real=real):
                self.put('to/report.docx', 'theirs')
                return real(p, d, job)
            with mock.patch.object(fo, '_' + op, side_effect=theirs_first):
                said = self.transfer(op, src)
            self.assertEqual(said, f'There is something called report.docx in the target already. '
                                   f'Nothing was {"moved" if op == "move" else "copied"}.')
            self.assertEqual((self.read('to/report.docx'), self.read('in/report.docx')), ('theirs', 'mine'))
            self.assertEqual(self.hidden('to'), [])
            os.unlink(self.dst)
tests/test_sec_review2.py, line 80: test_a_file_made_meanwhile_is_never_replaced

Every change, checked

  • More than 5,000 automated tests run on every change, on Debian 13, as on your server.
  • Nine kinds of checks must pass before a change can be built: the tests, two code checkers, the rules of the compiled build, the API reference, the desktop's scripts with their German and French, the documentation's links, the hand-over to this website, and the App Catalog.
  • Our threat model names every part of OSM that faces a network, and what holds there. We review it again and again, and each problem a review finds is fixed with the test that would have caught it.

The pieces are from OSM 0.3.0 (49ab072720fe). Found something? Write to security@osm-os.com.