ctl is a client for the App’s own CGI and adds no privilege: every call is made as the DSM account you signed in with, and the App’s backend decides. Commands and exit codes are in Run ctl commands; declaring commands is in Expose App commands.
| Layer | Comes from | Checked by | Refusal |
|---|
| Who you are | User password, plus OTP when DSM asks. DSM returns a session ID and a SynoToken. | DSM, at host add and host login. | Exit 2. |
| Which Apps are listed | The DSM package list, requested with your session. | DSM. | CTL_INVENTORY_DENIED, exit 4. |
| App entry | The App’s entry policy: API permissions (default), admin-only or app-privilege. See entry. | The App’s SDK, on every call. | app_privilege_denied or admin_required, shown as CTL_PERMISSION_DENIED, exit 4. |
| Method permission | permissions.json: public, authenticated or administrators per method. | The App’s SDK, on every call and every flow step. | CTL_PERMISSION_DENIED, exit 4. |
| Resource rules | Owner, ACL, grants and Shared Folder access, in the handler. | The App’s backend. | CTL_APP_ERROR, exit 5, with the App’s own code. |
- Every request carries your DSM cookie, your SynoToken and the NAS origin; the App authenticates them with DSM. ctl never calls a method with another identity, the package account, root or an API key.
- There are no API keys, service tokens or client credentials. Every session starts from a DSM sign-in.
- The command list is not a grant. A listed command can still be refused for your account.
- Capabilities that need an administrator’s approval inside the App (root operations, delegate, WebAPI profiles) keep that approval; ctl can neither grant nor skip it.
- Two approvals exist and neither replaces the other: the DSM administrator approves what an App may do on the NAS, and the person running ctl approves which installed Apps may receive their session for description discovery.
- A standalone App with the
identity capability uses dsm-app-session: ctl asks the App’s identity.session for a cookie limited to that package’s path (Secure, HttpOnly, no Domain), keeps it in memory for the call and calls identity.logout afterwards. Business methods still re-check DSM where the App requires it.
| Effect | Without --yes | With --yes |
|---|
read | Runs. | Runs. |
write | Runs nothing, returns the plan, exit 7. | Runs. |
destructive | Same as write. | Runs. |
--dry-run returns the redacted request plan and sends no business request.
destructive is a label for callers and agents, not a second confirmation. A delete that needs the user to see what will be removed must have that step in the App’s backend, for example a plan ID the user confirms.
host remove needs --yes or an interactive yes. Approving the description batch is a separate prompt (--approve-installed without a terminal).
--yes is neither the user’s authorization nor the App’s.
- No description endpoint is anonymous. ctl sends your session only to
/webman/3rdparty/<package>/cgi/api.cgi of packages in the approved batch, on the host you registered.
- The first valid description pins its SHA-256 hash with the version. A new version needs approval again. The same version with a different hash is refused (
CTL_DESCRIPTION_CHANGED) until you approve with --refresh --approve-installed.
- The hash identifies content. It is not an author signature, and
developedBy is self-declared. A NAS administrator who edits an installed package can change both; ctl does not defend against that.
- A package name or a CGI alone does not make an App. No valid description, no commands.
host revoke <host> <PackageID> withdraws one App’s approval and clears the host’s cache.
- A cache entry whose content ctl masked is not executable. ctl reads and verifies the original description again first.
- Cookie and token are bound to the registered origin. ctl never follows a redirect and never sends them elsewhere.
- Mark secrets in
paramsSchema and resultSchema with JSON Schema writeOnly: true, including nested properties, array items and local $ref targets. Combined schemas are masked if any branch is marked.
- ctl prints
<redacted> for them in dry runs, confirmation plans, JSON and multi-host output, schema errors, caches, and known input values that the App repeats. The request sent to the App keeps the real value.
- ctl does not log or cache business parameters, and schema errors never repeat your values.
- Typed flags are process arguments. Pass secrets with
--input - or a protected --input file.
- Do not put real secrets in
default, enum, examples or command examples of a description. Anyone who may open the App can read it.
| Item | Rule |
|---|
| Transport | HTTPS. http only for http://127.0.0.1 or http://[::1] with --ssh-tunnel. Use --ca for a private certificate authority. |
| Path | Fixed /webman/3rdparty/<package>/cgi/api.cgi of the package itself; no other host, port, query, .. or percent-escape. |
| Size and time | Request and response at most 1 MiB; 10 s per JSON request. ndjson at most 8 MiB, upload at most 16 GiB. |
| Replay | Never. A failed or timed-out request is not retried. |
| Session | Cookie, SynoToken and optional device token in the OS credential store. No plaintext fallback: without a usable store (for example a headless Linux runner without Secret Service) host add fails with CTL_CREDENTIAL_STORE. |
| Not stored | Password, OTP, business parameters. |
| Files | Host registration, approvals, hash pins and cache under ~/.synopkgland/ctl, mode 0600 in a 0700 directory. |
| Removal | host logout ends the DSM session and clears the local cookie and token. host remove --yes also deletes the device token, approvals, pins, cache and registration. A failed NAS logout is reported separately. |
| Not possible | Why |
|---|
| Call a method that no command binds, or an internal or UI method | Commands are an explicit allowlist; bindings carry the real permission. |
| Run scripts, shell, URLs, expressions or step graphs from metadata | Only the five fixed flows exist. |
| Send credentials to another origin or follow a redirect | Requests are bound to the registered origin. |
| Read a description anonymously | DSM session, SynoToken and App entry are required. |
| Retry or replay a write or a job start | The outcome after a failure is unknown; the caller checks first. |
| Resume or chunk an upload | The SDK has no generic chunk protocol. |
| Keep a current host, or rename a host | Every multi-host call names its hosts. |
| Generate descriptions for binary or Compose Apps | CTL_UNSUPPORTED_BACKEND; write the contract by hand. |
Replace a backend confirmation with --yes | --yes only unlocks the call. |
- Keep
permissions.json tight. The default is administrators; raise a method to authenticated only when ordinary users need it, and set entry deliberately.
- Validate again in the handler.
paramsSchema is checked by ctl only; any signed-in client can send other values to the CGI.
- Take the user from
caller.User(), never from a parameter, and check owner, ACL and grants in the handler.
- Declare the honest
effect; use destructive for irreversible work and keep plan identity, freshness and confirmation in the backend.
- Expose complete tasks, not proxies. No command that forwards an arbitrary method, path, URL or shell string.
- Treat the description as readable by every account that passes App entry: it lists every command and schema, including administrator-only ones. Put no secrets, internal URLs or hostnames in summaries or examples.
- Bound results. Paginate large lists; keep one response under 1 MiB.
- Do not log parameters, and do not echo secrets in results or errors.
- Make
poll and result methods read-only, and start a job once.
- Bump
version or build with every change that touches commands; callers must approve it again.
- Test with an ordinary account and an administrator, with
--dry-run and --yes.
- Register a dedicated, least-privileged DSM account as its own host (for example
nas-agent) and grant it only the Application Privileges it needs. Check that ctl list works for it.
- Read the batch before approving it. Use
host show to review approvals and pins, and do not approve on behalf of the user.
- Let an agent run reads freely and ask the user before
--yes. Always pass --host.
- Anyone who can read your OS credential store as you can act as you in every App your account may use, until
host logout. Log out when the work is done.
- In CI, supply the password through a secret and
--password-stdin, and use a runner with a credential store.
- NAS certificates are accepted by default. Use
--strict-tls or --ca <file> to enable verification.