T09 · Insecure Skill Coding Practices
- Location
SKILL.md:185- Finding
Unauthenticated Telegram Webhook Allows Fraudulent Credit Grants
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This payment skill is purpose-aligned but needs careful review because its sample webhook code can grant paid credits from unauthenticated Telegram payment requests and writes billing state based on untrusted data.
Install only after revising the payment server: authenticate Telegram webhooks with a secret token, validate pre-checkout and successful-payment data against server-side orders, use idempotency keys, strictly validate user IDs and path containment, pin dependencies, avoid direct public exposure of port 8001, and make payment wording transparent and locale-appropriate.
SKILL.md:185Unauthenticated Telegram Webhook Allows Fraudulent Credit Grants
SKILL.md:189Pre-Checkout Queries Are Approved Without Price or Package Validation
SKILL.md:135Attacker-Controlled User Identifier Is Used in a Filesystem Path
SKILL.md:285Runtime Installation Uses Unpinned Third-Party Dependencies
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).
payment_server.py (FastAPI, runs on port 8001)
"""
Unified payment webhook server.
Handles: Stripe webhooks + Telegram Stars pre_checkout_query + successful_payment
Run: uvicorn payment_server:app --host 0.0.0.0 --port 8001
"""
import json
import os
import pathlib
import httpx
from fastapi import FastAPI, Request, HTTPException
import stripe
app = FastAPI()
WORKSPACES = pathlib.Path(os.environ.get("WORKSPACES_DIR", "/workspaces"))
BOT_TOKEN = os.environ["TELEGRAM_BOT_TOKEN"]
STRIPE_WEBHOOK_SECRET = os.environ.get("STRIPE_WEBHOOK_SECRET", "")
stripe.api_key = os.environ.get("STRIPE_SECRET_KEY", "")
CREDIT_PACKAGES = {
"price_20": {"credits": 20, "price_id": "price_xxx"}, # replace with real Stripe price IDs
"price_50": {"credits": 50, "price_id": "price_yyy"},
"price_100": {"credits": 100, "price_id": "price_zzz"},
}
def add_credits(user_id: str, credits: int):
"""Add credits to user's usage.json."""
usage_file = WORKSPACES / user_id / "usage.js
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def notify_user(user_id: str, credits_added: int, total_credits: int):
"""Send Telegram message to user after successful payment."""
httpx.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={
"chat_id": user_id,
"text": f"✅ 充值成功!\n\n+{credits_added} 张图片额度\n剩余总额度:{total_credits} 张\n\n直接告诉我你想要什么吧 👇",
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def notify_user(user_id: str, credits_added: int, total_credits: int):
"""Send Telegram message to user after successful payment."""
httpx.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={
"chat_id": user_id,
"text": f"✅ 充值成功!\n\n+{credits_added} 张图片额度\n剩余总额度:{total_credits} 张\n\n直接告诉我你想要什么吧 👇",
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def notify_user(user_id: str, credits_added: int, total_credits: int):
"""Send Telegram message to user after successful payment."""
httpx.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={
"chat_id": user_id,
"text": f"✅ 充值成功!\n\n+{credits_added} 张图片额度\n剩余总额度:{total_credits} 张\n\n直接告诉我你想要什么吧 👇",
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def notify_user(user_id: str, credits_added: int, total_credits: int):
"""Send Telegram message to user after successful payment."""
httpx.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={
"chat_id": user_id,
"text": f"✅ 充值成功!\n\n+{credits_added} 张图片额度\n剩余总额度:{total_credits} 张\n\n直接告诉我你想要什么吧 👇",
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def notify_user(user_id: str, credits_added: int, total_credits: int):
"""Send Telegram message to user after successful payment."""
httpx.post(
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
json={
"chat_id": user_id,
"text": f"✅ 充值成功!\n\n+{credits_added} 张图片额度\n剩余总额度:{total_credits} 张\n\n直接告诉我你想要什么吧 👇",
The embedded code sends a hard-coded Chinese success message, and later sections prescribe Chinese-only paywall wording. This imposes a specific language on end users without offering a language choice or documenting a justified locale restriction, which is a natural-language policy concern.
The AGENTS.md snippet mandates specific Chinese phrases for quota and payment messaging and forbids alternative explanations. There is no indication that users can choose their language or that the skill is limited to a Chinese-only deployment context.
The AGENTS.md behavior explicitly says not to explain pricing logic and not to mention what Stripe or Stars are when triggering payment guidance. Because this markdown file defines a user-facing payment workflow that affects user spending, omitting basic disclosure about payment methods can leave users without adequate warning or context before interacting with purchase buttons.
The documentation says that when using Stripe Payment Links, credits can be stored in Product metadata and the webhook should read them from line_items. However, the actual webhook implementation at L171-L178 only reads session.get("metadata", {}).get("credits", 0) and never retrieves line_items or product metadata. This is an active contradiction between the documented integration behavior and the code path that actually grants credits.
No suspicious patterns detected.