Agent skill

Security Guide

by mobazha in mobazha/mobazha-unified

Comprehensive security development guide for Mobazha decentralized marketplace covering XSS prevention, Web3 transaction safety, key management, and input validation.

MPL-2.0Auto-check passedSecurity

Install Security Guide

skills CLI
$ npx skills add mobazha/mobazha-unified --skill security-guide -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mobazha/mobazha-unified security-guide --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mobazha/mobazha-unified.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.cursor/skills/security-guide .claude/skills/security-guide && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
security-guide
GitHub stars
165
Token cost
~1.7k tokens
SKILL.md length
227 words
Files
1
Skills in repo
29
Repo updated
First seen
Licence
MPL-2.0

At a glance

Comprehensive security development guide for Mobazha decentralized marketplace covering XSS prevention, Web3 transaction safety, key management, and input validation.

  • Working with user input
  • SKILL.md covers 项目安全现状, 一、XSS 防护, 二、Web3 交易安全 and 三、金额安全, plus 5 more sections
  • Calls npx; needs API_KEY
  • Wallet operations

What it does

Security Guide is an agent skill from mobazha/mobazha-unified. Comprehensive security development guide for Mobazha decentralized marketplace covering XSS prevention, Web3 transaction safety, key management, and input validation. Use when working with user input, wallet operations, transactions, or security-sensitive features, "安全", "XSS", "注入", "钱包安全", "合约安全", "密钥管理".

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Security, covering Web application vulnerabilities, Crypto and DeFi analysis and Cryptography. The repository describes itself as: Open-source commerce frontend for storefronts, marketplaces, checkout, and seller management. The licence is MPL-2.0.

When your agent uses it

  • Working with user input
  • Wallet operations
  • Security-sensitive features

Example prompts

  • “/security-guide”

Requirements

  • Node.js
  • A credential in API_KEY

What it can do on your machine

Read from SKILL.md and the folder at commit 156c699. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npx, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Security Guide loads about 1.7k tokens when it runs. Until then it costs about 81 tokens; SKILL.md has 227 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~81
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mobazha/mobazha-unified at commit 156c699, republished under its MPL-2.0 licence (© mobazha). 227 words, ~1,728 tokens.

Download SKILL.mdSave it as .claude/skills/security-guide/SKILL.md (or your agent's skills folder).
name
security-guide
description
Comprehensive security development guide for Mobazha decentralized marketplace covering XSS prevention, Web3 transaction safety, key management, and input validation. Use when working with user input, wallet operations, transactions, or security-sensitive features, "安全", "XSS", "注入", "钱包安全", "合约安全", "密钥管理".

安全开发指南

Mobazha 去中心化市场的安全开发规范和最佳实践。

项目安全现状

项目已有的安全基础设施:

  • packages/core/utils/htmlUtils.ts — DOMPurify HTML 清理
  • packages/core/services/api/wallet.ts — 地址验证 API
  • bignumber.js — 精确金额计算
  • ethers.js v6 — 地址规范化和签名
  • 外部钱包 Provider — 私钥永不暴露给前端

一、XSS 防护

1.1 HTML 内容处理

唯一允许的方式:使用项目已有的 sanitizeHtml():

typescript
import { sanitizeHtml, stripHtmlTags } from '@mobazha/core';

// 需要渲染 HTML 时(商品描述、店铺介绍)
<div dangerouslySetInnerHTML={{ __html: sanitizeHtml(htmlContent) }} />

// 只需要纯文本时
const plainText = stripHtmlTags(htmlContent);

配置说明(htmlUtils.ts):

  • 允许的标签:h1-h6, p, a, img, ul, ol, li, blockquote, code, pre, br, hr, strong, em, span, div, table, tr, td, th
  • 自动为 <a> 添加 target="_blank" rel="noopener noreferrer nofollow"
  • 移除所有 <script>, <iframe>, <object>, <embed>, on* 事件属性
1.2 URL 处理
typescript
// ❌ 危险
window.location.href = userInput;
<a href={userInput}>链接</a>

// ✅ 安全
const safeUrl = new URL(userInput, window.location.origin);
if (safeUrl.protocol === 'https:' || safeUrl.protocol === 'http:') {
  // 允许导航
}

二、Web3 交易安全

2.1 交易发送检查清单

每次发送链上交易前,必须验证:

typescript
// 1. 钱包已连接
if (!walletProvider) throw new Error('钱包未连接');

// 2. 链正确
const currentChainId = await provider.getNetwork().then(n => n.chainId);
if (currentChainId !== expectedChainId) {
  await switchNetwork(expectedChain);
}

// 3. 余额充足(含 gas)
const balance = await provider.getBalance(address);
const gasEstimate = await contract.method.estimateGas(...args);
const gasPrice = await provider.getFeeData();
const totalCost = amount + gasEstimate * gasPrice.maxFeePerGas;
if (balance < totalCost) throw new Error('余额不足');

// 4. 参数验证
const validAddress = ethers.getAddress(recipientAddress); // 会抛异常如果无效
2.2 Escrow 安全模式

项目的 Escrow 服务(packages/core/services/payment/escrow.ts)遵循:

typescript
// 创建 Escrow — 必须验证
async createNativeEscrow(params: EscrowParams) {
  // ✅ 地址规范化
  const seller = ethers.getAddress(params.sellerAddress);
  const moderator = ethers.getAddress(params.moderatorAddress);

  // ✅ Gas 预估
  const gasEstimate = await contract.createEscrow.estimateGas(...);

  // ✅ 交易确认(UI 层面必须二次确认)
  const tx = await contract.createEscrow(...);
  const receipt = await tx.wait(); // 等待链上确认

  return receipt;
}
2.3 签名安全
typescript
// ✅ 使用 EIP-712 结构化签名(用户可以看到签名内容)
const signature = await signer.signTypedData(domain, types, value);

// ⚠️ 避免盲签(用户无法理解签名内容)
// 仅在无法使用 EIP-712 时才使用 personal_sign
const signature = await signer.signMessage(message);

三、金额安全

3.1 必须使用 BigNumber
typescript
import BigNumber from 'bignumber.js';

// ✅ 所有金额计算使用 BigNumber
const total = new BigNumber(price).times(quantity);
const fee = total.times(0.01).decimalPlaces(8, BigNumber.ROUND_HALF_UP);

// ✅ 链上金额转换
import { toMinimalUnit, fromMinimalUnit } from '@mobazha/core';
const wei = toMinimalUnit(amount, decimals); // 用户金额 → 链上最小单位
const display = fromMinimalUnit(wei, decimals); // 链上最小单位 → 显示金额
3.2 精度陷阱
typescript
// ❌ 浮点运算精度丢失
0.1 + 0.2; // 0.30000000000000004

// ❌ toFixed 用于计算
parseFloat((0.1 + 0.2).toFixed(2)); // 可能不精确

// ✅ BigNumber 全程处理
new BigNumber('0.1').plus('0.2').toString(); // "0.3"

四、密钥与认证

4.1 绝对禁止
typescript
// ❌ 绝对禁止
localStorage.setItem('privateKey', key);
localStorage.setItem('mnemonic', phrase);
console.log('Token:', accessToken);
const API_KEY = 'sk-xxxxx'; // 硬编码密钥

// ✅ 敏感操作通过后端 API
const mnemonic = await walletApi.getMnemonic(); // 需要认证
await walletApi.restoreWallet(mnemonic); // 立即使用,不存储
4.2 允许存储的数据
数据类型存储位置示例
主题偏好localStoragemobazha-theme
购物车localStorage (Zustand persist)mobazha-cart-storage
UI 状态localStorage/sessionStoragepwa-install-dismissed
用户 sessionCookie (httpOnly, 后端设置)—
私钥/助记词❌ 禁止前端存储—

五、输入验证速查

输入类型验证方式
链上地址ethers.getAddress(addr) + walletApi.validateAddress()
金额!isNaN() + > 0 + <= balance + BigNumber 精度
商品价格parseFloat(price) > 0 + BigNumber
HTML 内容sanitizeHtml()
URLnew URL() + 协议白名单
搜索输入长度限制 + 特殊字符转义

六、后端安全(Go / Solidity)

6.1 Go 后端安全(mobazha_hosting / mobazha / mobazha.info)
go
// ❌ SQL 注入风险
query := fmt.Sprintf("SELECT * FROM users WHERE name = '%s'", userInput)

// ✅ 参数化查询
query := "SELECT * FROM users WHERE name = $1"
db.Query(query, userInput)
go
// ❌ 日志泄露敏感数据
log.Printf("User mnemonic: %s, token: %s", mnemonic, token)

// ✅ 日志脱敏
log.Printf("User authenticated: peerID=%s", peerID)

Go 后端安全要点:

  • 使用参数化查询或 SQLC(mobazha.info)防止 SQL 注入
  • JWT 中间件验证所有认证路由(mobazha_hosting api/gateway.go)
  • 日志禁止输出:私钥、助记词、JWT token、用户密码
  • 文件路径操作使用 filepath.Clean() 防止路径遍历
  • HTTP handler 必须设置合理的 MaxBytesReader 限制请求体大小
6.2 智能合约安全(bsc-smart-contracts)
solidity
// ❌ 重入攻击风险
function withdraw(uint amount) external {
    payable(msg.sender).transfer(amount);  // 外部调用在状态变更前
    balances[msg.sender] -= amount;
}

// ✅ Checks-Effects-Interactions 模式
function withdraw(uint amount) external nonReentrant {
    require(balances[msg.sender] >= amount, "Insufficient");
    balances[msg.sender] -= amount;  // 先变更状态
    payable(msg.sender).transfer(amount);  // 后外部调用
}

合约安全要点:

  • 使用 OpenZeppelin ReentrancyGuard 防止重入攻击
  • 所有数学运算使用 Solidity 0.8+ 内置溢出检查
  • Escrow 合约安全规范见 bsc-smart-contracts/contracts/escrow/EscrowSpec.md
  • 部署前必须通过完整测试套件:npx hardhat test

安全审查清单

前端
  • 用户输入的 HTML 是否经过 sanitizeHtml() ?
  • 金额计算是否使用 BigNumber?
  • 链上交易是否先做 gas 估算?
  • 敏感数据是否只在内存中处理,不持久化?
  • 合约调用是否有 try/catch?
  • 钱包操作前是否检查了连接状态和链 ID?
后端 (Go)
  • 数据库查询是否使用参数化查询?
  • 认证路由是否经过 JWT 中间件?
  • 日志是否已脱敏(无密钥、token 泄露)?
  • 文件路径是否使用 filepath.Clean() 处理?
智能合约
  • 是否使用 Checks-Effects-Interactions 模式?
  • 是否继承 ReentrancyGuard?
  • 状态变更函数是否 emit 事件?

相关功能文档

  • 钱包集成 — useWallet 安全注意事项、合约交互模式
  • 账号绑定 — OAuth 多账号绑定、Casdoor 认证流程
  • 各后端项目有独立的安全 rules(.cursor/rules/ 目录下)

© mobazha, MPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .cursor/skills/security-guide of mobazha/mobazha-unified.

Open the folder on GitHubat commit 156c699

Compare with similar skills

Security Guide next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Security Guide compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Security Guide this skillmobazha/mobazha-unified165—~1.7kAutomated safety check: PassMPL-2.0
Stellar DevVelaPayments/vela-payments131—~1.8kAutomated safety check: PassMIT
near-api-js Developer Guideinternet-court/internet-court-skill6.4k1 repos~4.1kAutomated safety check: PassCustom licence
Systematic Attackingmtarcure/claude-vibe-squad163—~3.6kAutomated safety check: PassMIT
Binance Token AuditTermiX-official/cryptoclaw100—~695Automated safety check: PassMIT
Solana Devsolana-foundation/solana-dev-skill574—~3.8kAutomated safety check: PassMIT

Similar skills

  • Stellar Dev

    VelaPayments/vela-payments

    End-to-end Stellar development playbook. An agent skill from VelaPayments/vela-payments.

    131 GitHub stars~1.8k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • near-api-js Developer Guide

    internet-court/internet-court-skill

    Reference for building with near-api-js v7 in TypeScript or JavaScript: accounts, keys, signing, contract calls, tokens, unit conversion and meta-transactions on NEAR.

    6.4k GitHub starsUsed in 1 repo~4.1k tokens
    Backend & APIsAuto-check passed
  • Systematic Attacking

    mtarcure/claude-vibe-squad

    A skill your agent uses for ALL authorized offensive-security / bug-bounty work — the single method to find, chain, prove, dedup, and package the highest-value (High/Critical) findings across every…

    163 GitHub stars~3.6k tokensUpdated 17 days ago
    SecurityAuto-check passed
  • Binance Token Audit

    TermiX-official/cryptoclaw

    Binance Web3 official skill — security audit for token contracts, detecting honeypots, rug pulls, and malicious functions across BSC, Base, Solana, and Ethereum.

    100 GitHub stars~695 tokensUpdated 4 mo ago
    SecurityAuto-check passed
  • Solana Dev

    solana-foundation/solana-dev-skill

    A skill your agent uses when user asks to "build a Solana dapp", "write an Anchor program", "create a token", "debug Solana errors", "set up wallet connection", "test my Solana program", "fuzz my…

    574 GitHub stars~3.8k tokensUpdated today
    Backend & APIsAuto-check passed
  • Security Review

    getsentry/skills

    Official

    Security code review for vulnerabilities. An agent skill from getsentry/skills.

    1k GitHub starsUsed in 4 repos~2.9k tokens
    SecurityAuto-check: notes

More from mobazha/mobazha-unified

All 29 skills in this repo
  • A11y Guide

    mobazha/mobazha-unified

    Accessibility guide for Mobazha following WCAG 2.1 AA standards including color contrast, reduced motion, ARIA patterns, keyboard navigation, focus management, and screen reader testing.

    165 GitHub stars~1.4k tokensUpdated 4 days ago
    Auto-check passed
  • API Reference

    mobazha/mobazha-unified

    Look up Mobazha backend API endpoints, request/response formats, and field mappings.

    165 GitHub stars~1.7k tokensUpdated 4 days ago
    Auto-check passed
  • Code Review

    mobazha/mobazha-unified

    Review code for quality, architecture consistency, and adherence to Mobazha project standards using confidence-based filtering.

    165 GitHub stars~464 tokensUpdated 4 days ago
    Auto-check passed
  • Code Simplifier

    mobazha/mobazha-unified

    Simplify and refine recently written code for clarity, consistency, and maintainability while preserving all functionality.

    165 GitHub stars~601 tokensUpdated 4 days ago
    Auto-check passed
  • Commit Helper

    mobazha/mobazha-unified

    Generate commit messages and run pre-commit validation following Mobazha conventions.

    165 GitHub stars~735 tokensUpdated 4 days ago
    Auto-check passed
  • Component Dev

    mobazha/mobazha-unified

    Create and modify UI components following Mobazha conventions including directory structure, spacing standards, accessibility, and testing.

    165 GitHub stars~638 tokensUpdated 4 days ago
    Auto-check passed

Questions about Security Guide

What does Security Guide do?

Comprehensive security development guide for Mobazha decentralized marketplace covering XSS prevention, Web3 transaction safety, key management, and input validation. Security Guide is an agent skill from mobazha/mobazha-unified. Comprehensive security development guide for Mobazha decentralized marketplace covering XSS prevention, Web3 transaction safety, key management, and input validation.

When should I use Security Guide?

Security Guide fits situations like: working with user input; wallet operations; security-sensitive features.

How do I install Security Guide in Claude Code?

Run `npx skills add mobazha/mobazha-unified --skill security-guide -a claude-code`. Or copy the skill folder (.cursor/skills/security-guide in mobazha/mobazha-unified) into .claude/skills/security-guide in your project. Claude Code loads it when a task matches its description.

How do I install Security Guide in Codex?

Run `npx skills add mobazha/mobazha-unified --skill security-guide -a codex`. Or copy the skill folder (.cursor/skills/security-guide in mobazha/mobazha-unified) into .agents/skills/security-guide in your project. Codex loads it when a task matches its description.

Can I use Security Guide in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mobazha/mobazha-unified --skill security-guide -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/security-guide, .gemini/skills/security-guide, .github/skills/security-guide and .opencode/skills/security-guide in your project.

What does Security Guide need to run?

Going by SKILL.md and its folder, Security Guide needs the command-line tools its instructions call (npx) and credentials named API_KEY. Our summary lists: Node.js; A credential in API_KEY.

Does Security Guide access the network?

SKILL.md contains no URLs. Its commands use npx, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Security Guide safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Security Guide use?

Security Guide is published under the MPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Security Guide use?

About 1.7k tokens (SKILL.md is roughly 6.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Security Guide?

Skills that share tags, products or a category with Security Guide: Stellar Dev (VelaPayments/vela-payments, 131 stars), near-api-js Developer Guide (internet-court/internet-court-skill, 6.4k stars), Systematic Attacking (mtarcure/claude-vibe-squad, 163 stars) and Binance Token Audit (TermiX-official/cryptoclaw, 100 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Security Guide?

mobazha (a GitHub organization) maintains it in mobazha/mobazha-unified, which has 165 GitHub stars. The repository holds 29 skills in this directory. The repository was last updated on October 3, 2026.

Source: mobazha/mobazha-unified on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.