csharp-database-secure-no-railguard-available

csharp-database-secure-no-railguard-available is a cursor rule for Cursor from brighton-labs/railguard-cursor-coding. It costs 966 tokens per session, scanned A, original, MIT.

A set of rules for secure database access in C# applications, covering ADO.NET, Entity Framework Core, SQL queries, credentials, input handling, and logs. ADO.NET and Entity Framework Core are common ways for C# code to work with databases.

In plain words
What is it for?
Use it when writing or reviewing C# code that connects to a database, builds queries, uses an ORM, or handles database errors and credentials.
Why use it?
It reduces risks such as SQL injection, exposed credentials, unsafe database settings, and sensitive data appearing in logs.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/brighton-labs/railguard-cursor-coding/csharp-database-secure-no-railguard-available
Clone the repo
git clone --depth 1 https://github.com/brighton-labs/railguard-cursor-coding

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for csharp-database-secure-no-railguard-available

README.md
[![agentmods](https://agentmods.dev/badge/rules/brighton-labs/railguard-cursor-coding/csharp-database-secure-no-railguard-available.svg)](https://agentmods.dev/rules/brighton-labs/railguard-cursor-coding/csharp-database-secure-no-railguard-available)
Your own site
<a href="https://agentmods.dev/rules/brighton-labs/railguard-cursor-coding/csharp-database-secure-no-railguard-available"><img src="https://agentmods.dev/badge/rules/brighton-labs/railguard-cursor-coding/csharp-database-secure-no-railguard-available.svg" alt="Measured on agentmods" height="20"></a>
Per session 966 This file is loaded in full into every session.
When invoked 966 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00966 $0.00966
Opus 5 $0.00483 $0.00483
Sonnet 5 $0.00193 $0.00193
Haiku 4.5 $0.00097 $0.00097

Measured 5d ago against content hash 04b99580aaea, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

csharp-database-secure-no-railguard-available scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/csharp-database-secure-no-railguard-available.mdc · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

R: Risk First

The goal of this rule is to ensure safe, auditable, and robust database access in C# applications.

Key risks mitigated:

  • SQL injection via unsafe query strings
  • Hardcoded or leaked credentials
  • Misconfigured or unsafe ORM operations
  • Lack of input validation in query construction
  • Logging of sensitive database values

This rule prepares the model to reason securely about database operations, regardless of whether the user explicitly mentions injection, credentials, or ORM.

A: Attached Constraints

  • Never use string concatenation to build SQL queries.
  • Never log raw SQL statements containing user-provided data.
  • Never hardcode sensitive values (for example, DB credentials) in source code.
  • Use SqlCommand with Parameters.Add() or LINQ-to-Entities.
  • ORM operations must use proper configuration and input protection.
  • Always wrap raw ADO.NET operations in a try/catch block and check exceptions.

I: Interpretative Framing

  • If the prompt involves DB access, assume secure credential loading and parameter binding are required.
  • If EF Core is mentioned or used, enforce use of LINQ and strongly typed models.
  • If manual SQL is required, enforce use of SqlCommand.Parameters.Add() and no dynamic string interpolation.
  • If secrets are referenced, redirect to using .NET Secret Manager, Azure Vault, or environment-based config.

// Examples:

  • If the user says “select user by name,” the model must return code that uses a parameterized query.
  • If SqlConnection is used, assume a config-based ConnectionString source.

L: Local Defaults

  • ORM: Entity Framework Core with DbContext, DbSet<T>
  • Credential source: appsettings.json or environment variables
  • Default DB logging behavior should avoid showing queries with raw input
// appsettings.json
"ConnectionStrings": {
  "DefaultConnection": "Server=...;Database=...;User Id=...;Password=...;"
}

G: Generative Path Checks

  1. Determine if ORM is present (EF Core)
  2. If not, enforce parameterized query via SqlCommand
  3. Sanitize all input values before adding them as parameters
  4. Never build SQL using string interpolation ($"...") or +
  5. Ensure try-catch-finally or using-disposal pattern is applied
  6. Check logging or error messages for any exposed sensitive data

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 88 lines · 966 tokens per session scan A 04b99580aaea

Subscribe to this mod's changes

csharp-database-secure-no-railguard-available is a cursor rule published in the GitHub repository brighton-labs/railguard-cursor-coding (13 stars, last pushed 1y ago), licensed MIT. It adds 966 tokens to every session, about $0.0048 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.