github coddingtonbear/obsidian-local-rest-api 5.6.0

41 minutes ago

This release fixes a path traversal hole that could let an API client read and write files outside your vault (GHSA-h363-vqpq-479g), and now requires Obsidian 1.15.1. It also shows the settings page in Chinese when Obsidian is set to Chinese, and tells you when a server can't start because its port is taken instead of failing silently.

At a glance

Features

  • Settings page in Chinese — the settings page was English-only

Bug fixes

  • .. paths could reach a folder named vault outside the vault — the containment check could be fooled by a path that climbed out and came back in under that name
  • A port conflict stopped the server with no explanation — most often hit with the plugin enabled in two open vaults
  • API key comparison leaked timing — the key check stopped at the first wrong character

Features

Settings page in Chinese: the settings page was English-only

The settings page now follows Obsidian's language setting. When Obsidian is set to Chinese, every label, description and warning on it is shown in Simplified Chinese; Traditional Chinese settings get the Simplified strings too until a separate translation exists. Any string that hasn't been translated falls back to English rather than showing a blank. (#399; thanks @kmizmal!)

Bug fixes

.. paths could reach a folder named vault outside the vault

The problem: The plugin checked that a path stayed inside the vault by resolving it against a stand-in root named /vault. Resolving can't climb above /, so ../vault/x.md, ../../vault/x.md and a/../../vault/x.md all came out as /vault/x.md and passed the check. Obsidian then joined the original path onto your real vault directory, which put it in a folder named vault next to or above your vault. A client holding your API key could read, create, overwrite, delete, move and copy files there. If a folder above your vault is itself named vault (for example ~/vault/Notes), the same trick also got past the guard on Obsidian's configuration directory, which means a client could replace another plugin's code.

This was reported privately and has been reproduced in testing. The precondition is a folder named vault somewhere above (or beside) your vault; if there isn't one, these paths were already refused. (GHSA-h363-vqpq-479g; thanks @kyanagisawa-dev for the report!)

What's new: Any path containing a .. segment is now refused with a 400 (error code 40021), on every REST endpoint, every MCP tool and signed URLs, including the Destination of MOVE and COPY. That includes paths like notes/../a.md that would have resolved back inside the vault; see Breaking changes below. On top of that, the plugin now requires Obsidian 1.15.1, whose file adapter refuses .. paths on its own, so there are two independent checks in the way instead of one. (#407)

A port conflict stopped the server with no explanation

The problem: When a server couldn't bind its port, the error went uncaught and the API simply didn't start, with nothing shown to you. Ports are a per-vault setting and every vault starts on 27124 (HTTPS) and 27123 (HTTP), so the easiest way to hit this was enabling the plugin in a second vault while the first was open.

What's new: A server that can't bind now shows a notice naming the port and the reason: the port is already in use (possibly by this plugin in another vault), needs elevated privileges, or the binding host isn't an address on this machine. The same reason appears next to the server under Settings → Local REST API → Server status, and updates when you change the port. Choose a different port in one of the vaults to fix it. The plugin never changes a port on its own, since tools that talk to it may expect the defaults. (#398; thanks @BozhengLong!)

Obsidian doesn't show notices for a window that isn't focused, so if several vaults open at startup, the one in the background may only show the reason in its settings and the developer console.

Also fixed

  • The API key check compared the key character by character and stopped at the first mismatch, so a client that could time responses precisely enough could learn how much of a guessed key was right. The comparison now takes the same time whatever the guess, which together with the throttle on wrong keys added in 5.4.0 closes that off. (#394; thanks @ChristophPfeuffer!)

Breaking changes and migration

What changed: Two things, both part of the path traversal fix above.

  • Obsidian 1.15.1 or later is required. On older versions, Obsidian won't offer you this update.
  • Paths containing .. are refused, even ones that stay inside the vault. notes/../a.md used to be read as a.md; it's now a 400 with error code 40021. This applies to signed URLs too.

You are affected if you...

  • run an Obsidian version older than 1.15.1, or
  • have a script or tool that builds vault paths by joining relative pieces and sends them without normalizing them first.

Not affected: anyone sending the paths Obsidian itself uses. No path Obsidian produces contains .., and paths from GET /vault/, search results or the document map are all already normalized.

What to try first:

  • On an older Obsidian: update Obsidian, then the plugin.
  • If a tool starts getting 40021: normalize the path before sending it (resolve the .. yourself, so notes/../a.md becomes a.md).

There's no setting to turn the .. refusal off, since that's the fix.

Don't miss a new obsidian-local-rest-api release

NewReleases is sending notifications on new releases.