agentsclimarketplace

Security hardening gcp

Skill TakuroFukamizu/google-ai-studio-to-prod-skills/skills/security-hardening-gcp

Use when hardening GCP security for a deployed Gemini or AI application, configuring IAM least-privilege, Secret Manager, VPC, or reviewing GCP security postureFrom its SKILL.md

Install
npx -y skills add TakuroFukamizu/google-ai-studio-to-prod-skills --skill security-hardening-gcp

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

5.0 KB, as published. Nobody here has run it

Security Hardening for GCP

Overview

Secure a Gemini API application deployed on GCP. Covers IAM least-privilege, Secret Manager, network security, and common attack surfaces specific to AI applications.

When to Use

  • User says "セキュリティ設定して", "secure my deployment", "harden GCP"
  • After initial deployment, before going to production traffic
  • Security review of an existing GCP deployment

Security Checklist

AreaActionPriority
SecretsAPI keys in Secret Manager, not env varsCritical
firebase-applet-config.jsonapiKey を環境変数化、git history から除去Critical
IAMDedicated service account with minimal rolesCritical
API Key 制限Firebase Web API Key にHTTPリファラー制限を設定Critical
AuthCloud Run --no-allow-unauthenticated for internal servicesHigh
NetworkVPC connector if accessing internal resourcesHigh
LoggingCloud Audit Logs enabledMedium
EgressRestrict outbound to Gemini API endpoints onlyMedium

IAM — Least Privilege

Dedicated Service Account

# Create SA
gcloud iam service-accounts create gemini-app-sa \
  --display-name="Gemini App Service Account"

# Grant only what's needed
gcloud projects add-iam-policy-binding PROJECT_ID \
  --member="serviceAccount:gemini-app-sa@PROJECT_ID.iam.gserviceaccount.com" \
  --role="roles/secretmanager.secretAccessor"

# Deploy with dedicated SA
gcloud run deploy my-gemini-app \
  --service-account=gemini-app-sa@PROJECT_ID.iam.gserviceaccount.com

Roles to Avoid

RoleWhyUse Instead
roles/ownerGod modeSpecific roles
roles/editorToo broadSpecific roles
roles/secretmanager.adminCan create/delete secretssecretAccessor

Secret Manager

# Create secret
echo -n "AIzaSy..." | gcloud secrets create gemini-api-key --data-file=-

# Grant access to SA
gcloud secrets add-iam-policy-binding gemini-api-key \
  --member="serviceAccount:gemini-app-sa@PROJECT_ID.iam.gserviceaccount.com" \
  --role="roles/secretmanager.secretAccessor"

# Reference in Cloud Run
gcloud run deploy my-gemini-app \
  --set-secrets="GEMINI_API_KEY=gemini-api-key:latest"

firebase-applet-config.json の API Key

AI Studio が生成するプロジェクトでは firebase-applet-config.json に Firebase Web API Key が平文で含まれる。Firebase Web API Key は本来クライアントサイドで使う前提だが、API Key に利用制限がなければ第三者が悪用可能。

対策:

  1. apiKey を環境変数に外出し → export-from-ai-studio スキル参照
  2. Google Cloud Console → APIs & Services → Credentials で API Key に制限を追加:
    • アプリケーション制限: HTTP リファラー(自分のドメインのみ許可)
    • API 制限: 必要な API のみ(Firebase Auth, Firestore, etc.)
  3. git history に残っている場合は Key をローテーション
# API Key の一覧確認
gcloud services api-keys list --project=PROJECT_ID

# 新しい Key を作成し、制限を追加
gcloud services api-keys create --display-name="firebase-web-restricted" \
  --allowed-referrers="https://your-domain.com/*" \
  --api-target=service=firestore.googleapis.com \
  --api-target=service=identitytoolkit.googleapis.com

AI-Specific Security

RiskMitigation
Prompt injectionInput validation + output sanitization
API key leakageSecret Manager + key rotation + firebase-applet-config.json サニタイズ
Cost explosionBudget alerts + quota limits
Data exfiltration via promptsLog and monitor all Gemini API calls
Model abuseRate limiting per user

Implementation Steps

  1. Create dedicated service account with minimal roles
  2. Migrate all secrets to Secret Manager
  3. Set budget alerts — gcloud billing budgets create
  4. Enable Cloud Audit Logs for the project
  5. Configure rate limiting — Cloud Armor or application-level
  6. Set up Gemini API quota — Limit requests/min in Cloud Console
  7. Review IAM — Remove overly broad roles

Common Mistakes

  • firebase-applet-config.json を未サニタイズでコミット — AI Studio デフォルトで apiKey が平文。export-from-ai-studio で必ず環境変数化する
  • Using default compute SA — Has roles/editor by default, way too broad
  • API key in Dockerfile ENV — Baked into image layer, visible in registry
  • Firebase Web API Key に制限なし — リファラー制限と API 制限を必ず設定
  • No budget alerts — A prompt injection loop can burn through API quota fast
  • --allow-unauthenticated on internal services — Only for public-facing endpoints

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.