Skip to content
Back to skills

Detecting Off By One

ASecurity

Detects off-by-one errors by identifying incorrect loop conditions, array indexing mistakes, and boundary condition problems. Use when analyzing loops, array access, or investigating fencepost errors.

  • 666 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added February 8, 2026
code-qualitysecurity

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill detecting-off-by-one --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Detecting Off By One?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Detecting Off By One
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-detecting-off-by-one/badge)](https://www.skillsdirectory.com/skills/majiayu000-detecting-off-by-one)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: detecting-off-by-one
description: Detects off-by-one errors by identifying incorrect loop conditions, array indexing mistakes, and boundary condition problems. Use when analyzing loops, array access, or investigating fencepost errors.
---

# Off-by-One Detection

## Detection Workflow

1. **Identify array operations**: Find all array accesses, loop iterations, buffer allocations, string operations
2. **Analyze boundary conditions**: Check loop termination conditions, array index ranges, buffer size calculations
3. **Check edge cases**: Test boundary conditions, verify fencepost cases, assess null terminator handling
4. **Assess impact**: Can off-by-one cause overflow/underflow? What's the security impact?

## Key Patterns

- Loop bound errors: using <= instead of <, or < instead of <=
- Array index errors: accessing array[size] instead of array[size-1]
- String handling errors: missing null terminator, incorrect buffer size
- Allocation errors: allocating size instead of size+1

## Output Format

Report with: id, type, subtype, severity, confidence, location, vulnerability, loop condition, array access, array size, error type, exploitability, attack scenario, impact, mitigation.

## Severity Guidelines

- **HIGH**: Off-by-one causing buffer overflow
- **MEDIUM**: Off-by-one causing information disclosure
- **LOW**: Off-by-one with minor impact

## See Also

- `patterns.md` - Detailed detection patterns and exploitation scenarios
- `examples.md` - Example analysis cases and code samples
- `references.md` - CWE references and mitigation strategies

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.