meteor/agent-skills

meteor-security

Use when auditing or hardening a Meteor 3 application.

ソースを見る

使い方

  1. インストールコマンドをコピーし、自分の環境へ導入する前にソースを確認します。
  2. 必要なツール、認証情報、対応環境を原文で確認します。
  3. 入力と成果物を指定し、出力を資料と照合します。
npx skills add https://github.com/meteor/agent-skills --skill meteor-security

開始前の確認

  • 導入にはモデル契約、API枠、ファイルへのアクセス許可は含まれません。
  • スター数や導入数は活動の指標であり、独立した品質・安全性試験ではありません。
リポジトリの原文

見出し、例、コード、表、リンク、参照画像を含む原文を表示しています。

Meteor security

Meteor's security model is opinionated: the server holds authority, the client cannot be trusted, and the only places that filter data before it reaches users are methods (write paths) and publications (read paths).

Decision flow

  1. Audit every method: does it check() every argument and guard on

this.userId or Meteor.userId() when authentication matters?

  1. Audit every publication: does it filter by this.userId (when

user-specific) and project columns with fields?

  1. Add audit-argument-checks in dev to catch missing check().
  2. Add browser-policy and configure CSP.
  3. Add DDPRateLimiter rules for sensitive methods (login, password

reset, resource creation).

  1. If the app uses OAuth, set oauthSecretKey to encrypt provider

secrets at rest.

  1. Remove allow / deny rules. They are legacy and easy to misuse;

use methods instead.

Method guard checklist

javascript
import { Meteor } from "meteor/meteor";
import { check, Match } from "meteor/check";

Meteor.methods({
  async updateProfile(payload) {
    check(payload, { displayName: String, bio: Match.Optional(String) });
    if (!this.userId) {
      throw new Meteor.Error("not-authorized");
    }
    await Meteor.users.updateAsync(this.userId, { $set: { profile: payload } });
  },
  async updateAddress(payload) {
    check(payload, String);
    if (!Meteor.userId()) {
      throw new Meteor.Error("not-authorized");
    }
    await Meteor.users.updateAsync(Meteor.userId(), { $set: { address: payload } });
  },
});

Reject any method that does not match: check on every argument, userId gate when needed, Meteor.Error(code, reason) for failures, *Async Mongo on the server.

Publication guard checklist

javascript
Meteor.publish("items.mine", function () {
  if (!this.userId) return this.ready();
  return Items.find(
    { ownerId: this.userId },
    { fields: { title: 1, qty: 1 }, limit: 200 },
  );
});

Reject any publication that returns an unbounded cursor, omits the field projection, or skips a userId filter on user-specific data.

CSP via browser-policy

bash
meteor add browser-policy
javascript
// server top-level or inside Meteor.startup
import { BrowserPolicy } from "meteor/browser-policy-common";
import { Meteor } from "meteor/meteor";

Meteor.startup(async () => {
  await BrowserPolicy.content.disallowInlineScripts();
  BrowserPolicy.content.disallowEval();
  BrowserPolicy.framing.disallow();
});

BrowserPolicy is server-only. Configure it during module initialization or startup so every request receives one deterministic process-wide policy. The current implementation invalidates its cached CSP after a mutation, but do not mutate this global policy per request or per user. See references/browser-policy-csp.md for recipes (Stripe, Google Maps, fonts, inline-style allowance).

DDPRateLimiter for sensitive methods

javascript
import { DDPRateLimiter } from "meteor/ddp-rate-limiter";

DDPRateLimiter.addRule(
  {
    type: "method",
    name: "login",
    clientAddress: () => true,
  },
  5,
  60000,                  // 5 attempts per 60s, per IP
);

Only matcher fields contribute to the rate-limit bucket key. Without clientAddress, connectionId, or userId, every matching caller shares one global bucket. Meteor 3.5+ permits async matcher functions for database-backed decisions; keep their queries fast because the connection waits for them. On Meteor 3.0 through 3.4, matchers must stay synchronous. Use a fixed rule, precomputed synchronous state, or upgrade rather than awaiting Mongo there.

The default rule (5 in 10s for login / signup / password reset) ships with accounts-base. Remove with Accounts.removeDefaultRateLimit() only if you replace it.

OAuth secret encryption

Add oauth-encryption and pass a 16-byte base64 key (NOT 32 bytes) to Accounts.config at module top level (not inside Meteor.startup):

bash
meteor node -e "console.log(require('crypto').randomBytes(16).toString('base64'))"
javascript
import { Accounts } from "meteor/accounts-base";

Accounts.config({
  oauthSecretKey: Meteor.settings.oauthSecretKey,
});

At startup, accounts-oauth seals an unsealed provider application secret at ServiceConfiguration.configurations.secret. Provider packages also seal supported per-user token fields, such as services.github.accessToken or Twitter's accessTokenSecret. There is no generic Meteor.users.services.<provider>.secret field. Inspect the provider schema before asserting which user credential is encrypted.

audit-argument-checks

bash
meteor add audit-argument-checks

Throws if any method or publication runs without check() covering every argument. Methods that legitimately accept arbitrary input declare this explicitly:

javascript
Meteor.methods({
  rawLog(...args) {
    check(args, [Match.Any]);
    // ...
  },
});

Anti-patterns

  • Collection.allow / Collection.deny rules. Legacy; easy to combine

into a soft-fail. Replace with methods.

  • Meteor.settings.public.<secret>. The client sees public. Move

secrets to the top level of settings.json.

  • Publish the entire Meteor.users collection. Always project (e.g.

fields: { username: 1, profile: 1 }) and filter. Publish email only to the owning user or another explicitly authorized audience.

  • Use BrowserPolicy.content.allowOriginForAll for a third-party script. It

grants the origin to every current content directive. Allow only the script, frame, connect, image, style, or font directives the integration needs.

  • Methods that accept callback-shaped arguments. Functions cannot travel

over DDP.

  • Call Accounts.config({ oauthSecretKey }) inside Meteor.startup.

Must be at module top level so it loads before the OAuth packages read it.

See also

  • references/method-and-publish-guards.md
  • references/browser-policy-csp.md
  • references/eval-cases.md
  • Related skills: meteor-methods, meteor-pubsub, meteor-accounts.

タスクに関連する項目

同じリポジトリから

関連する Skills

すべての Skills
meteor
コミュニティ

meteor-cli-installation

Use when installing, locating, repairing, resetting, or uninstalling the Meteor CLI for Meteor 3 development. Triggers on "meteor: command not found", npx meteor, installer failures, PATH problems, specific Meteor versions, clean reinstall requests, meteor reset, or corrupted dev bundles. Use this skill when the user asks about fresh workstation setup or making a local Meteor command available. For application failures after the CLI starts, use meteor-debugging; for application code upgrades, us

導入数
1
GitHub Stars
10
更新日
10月14日
meteor
コミュニティ

meteor-debugging

Use when diagnosing an unexplained failure in a Meteor 3 application before the failing layer or fix is known. Triggers on server crashes, client-only errors, stuck subscriptions, DDP or WebSocket disconnects, Minimongo/server data mismatches, hanging or flaky tests, slow builds, --inspect, console.log, .only, Playwright traces, Instrumentation lifecycle events, or requests to debug a Meteor app. Use this skill when evidence must distinguish Meteor tool, server, client, data, test, browser, mobi

導入数
1
GitHub Stars
10
更新日
10月14日
meteor
コミュニティ

meteor-methods

Use when authoring or debugging Meteor methods (Meteor.methods, Meteor.call, Meteor.callAsync). Triggers on argument validation with check(), optimistic UI stubs, latency compensation, Meteor.Error handling, and DDPRateLimiter. Use this skill when the user asks about server-side mutation, asks about rate limiting RPC, or asks about wrapping a method with auth checks.

導入数
1
GitHub Stars
10
更新日
10月14日
meteor
コミュニティ

meteor-pubsub

Use when authoring or debugging Meteor publications and subscriptions (Meteor.publish, Meteor.subscribe). Triggers on publication strategies (SERVERMERGE, NOMERGE, NOMERGENOHISTORY), the low-level publish API (added/changed/removed), cursor authorization, reactive joins, leaked documents. Use this skill when the user asks about pub/sub or asks about reactive data fetching.

導入数
1
GitHub Stars
10
更新日
10月14日