

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
123456# Rails Security Guide78## Core Philosophy910- Security is not optional, it's fundamental11- Follow the principle of least privilege12- Never trust user input13- Defense in depth - multiple layers of security14- Stay updated with security best practices1516## Authentication Principles1718- Use Rails built-in authentication generator19- Implement secure password requirements20- Use has_secure_password for password handling21- Implement session timeouts22- Support multi-factor authentication when needed2324## Authorization Strategy2526- Authenticate every request27- Authorize every action28- Fail closed - deny by default29- Check permissions at multiple levels30- Log authorization failures3132## Strong Parameters3334- Always use strong parameters35- Whitelist allowed attributes explicitly36- Never permit entire parameter hashes37- Handle nested attributes carefully38- Document permitted parameters3940## SQL Injection Prevention4142- Use parameterized queries always43- Avoid string interpolation in queries44- Use Active Record query interface45- Sanitize user input when necessary46- Review raw SQL carefully4748## Cross-Site Scripting (XSS)4950- Escape output by default51- Use Rails sanitize helpers appropriately52- Be careful with raw and html_safe53- Implement Content Security Policy54- Validate and sanitize user input5556## Cross-Site Request Forgery (CSRF)5758- Enable CSRF protection globally59- Include tokens in all forms60- Verify tokens on state-changing requests61- Handle AJAX requests properly62- Document any CSRF exceptions6364## Session Security6566- Use secure session storage67- Implement session expiration68- Regenerate session IDs after login69- Clear sessions on logout70- Monitor for session hijacking7172## Password Management7374- Enforce strong password policies75- Never store passwords in plain text76- Use bcrypt for password hashing77- Implement password reset securely78- Support password managers7980## API Security8182- Use token-based authentication83- Implement rate limiting84- Version APIs from the start85- Use HTTPS exclusively86- Validate API input thoroughly8788## File Upload Security8990- Validate file types and sizes91- Scan uploads for malware92- Store files outside web root93- Use random filenames94- Implement access controls9596## Secrets Management9798- Use Rails credentials for secrets99- Never commit secrets to version control100- Rotate credentials regularly101- Use different credentials per environment102- Document credential requirements103104## HTTPS and Transport Security105106- Force SSL in production107- Use secure cookies108- Implement HSTS headers109- Validate SSL certificates110- Monitor certificate expiration111112## Security Headers113114- Implement Content Security Policy115- Use X-Frame-Options116- Set X-Content-Type-Options117- Enable X-XSS-Protection118- Configure Referrer-Policy119120## Input Validation121122- Validate on multiple levels123- Use Active Record validations124- Implement format validations125- Check business logic constraints126- Sanitize for output context127128## Error Handling129130- Don't expose sensitive information131- Log security events appropriately132- Use generic error messages133- Monitor for attack patterns134- Implement proper 404/500 pages135136## Dependency Security137138- Keep dependencies updated139- Monitor for vulnerabilities140- Use bundle audit regularly141- Review new dependencies142- Remove unused dependencies143144## Rate Limiting145146- Implement request throttling147- Limit authentication attempts148- Protect expensive operations149- Use progressive delays150- Monitor for abuse patterns151152## Logging and Monitoring153154- Log security-relevant events155- Avoid logging sensitive data156- Monitor for suspicious patterns157- Set up security alerts158- Review logs regularly159160## Data Protection161162- Encrypt sensitive data at rest163- Use encryption in transit164- Implement data retention policies165- Support data deletion requests166- Audit data access167168## Third-Party Integrations169170- Validate webhook signatures171- Use OAuth appropriately172- Limit API permissions173- Monitor third-party access174- Document integration security175176## Security Testing177178- Include security in test suite179- Test authorization thoroughly180- Verify input validation181- Check for common vulnerabilities182- Use security scanning tools183184## Incident Response185186- Have a response plan ready187- Document security contacts188- Practice incident procedures189- Monitor for breaches190- Learn from incidents191192## Compliance Considerations193194- Understand regulatory requirements195- Implement necessary controls196- Document security measures197- Conduct regular audits198- Stay informed on changes199200## Development Practices201202- Review code for security issues203- Use security linters204- Train team on security205- Follow secure coding standards206- Make security part of culture207208## Common Vulnerabilities209210- Mass assignment vulnerabilities211- Insecure direct object references212- Missing authorization checks213- Weak authentication methods214- Insufficient logging215216## Security Checklist217218- [ ] Authentication implemented properly219- [ ] Authorization checked everywhere220- [ ] Input validated and sanitized221- [ ] Output escaped appropriately222- [ ] HTTPS enforced in production223- [ ] Secrets managed securely224- [ ] Dependencies kept updated225- [ ] Security headers configured226- [ ] Logging implemented properly227- [ ] Error handling reveals no secrets228229## Best Practices Summary230231- Never trust user input232- Implement defense in depth233- Keep dependencies updated234- Log security events235- Stay informed on threats236237Remember: Security is everyone's responsibility. Build it in from the start, not as an afterthought.238
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| levifig/rails-instructions.github/instructions/rails-controllers.instructions.md · 54 | Copilot instructions | teststylesecurityapi+1 | 56/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-models.instructions.md · 54 | Copilot instructions | teststylearchtypes+4 | 60/100 | 14 days ago | |
| levifig/rails-instructions.cursor/rules/rails-rules.mdc · 54 | Cursor rules | testlint-formatstylearch+9 | 84/100 | 14 days ago | |
| levifig/rails-instructions.github/copilot-instructions.md · 54 | Copilot instructions | teststyletesting-strategysecurity+4 | 71/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-api.instructions.md · 54 | Copilot instructions | testlint-formatstyletesting-strategy+7 | 67/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-services.instructions.md · 54 | Copilot instructions | teststylearchtesting-strategy+4 | 75/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-background-jobs.instructions.md · 54 | Copilot instructions | teststyletesting-strategydatabase+2 | 63/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-core.instructions.md · 54 | Copilot instructions | teststylearchtesting-strategy+5 | 68/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-deployment.instructions.md · 54 | Copilot instructions | setupstylesecuritydatabase+2 | 52/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-hotwire.instructions.md · 54 | Copilot instructions | teststylesecurityperformance+1 | 56/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-importmaps.instructions.md · 54 | Copilot instructions | teststylesecuritydatabase+2 | 56/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-mobile.instructions.md · 54 | Copilot instructions | styleuiperformance | 66/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-performance.instructions.md · 54 | Copilot instructions | teststylegitdatabase+2 | 56/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-styling.instructions.md · 54 | Copilot instructions | styledatabaseuiperformance+3 | 59/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-testing.instructions.md · 54 | Copilot instructions | teststyletesting-strategysecurity+2 | 56/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails-views.instructions.md · 54 | Copilot instructions | teststylearchsecurity+3 | 60/100 | 14 days ago | |
| levifig/rails-instructions.github/instructions/rails.instructions.md · 54 | Copilot instructions | testlint-formatstylearch+9 | 84/100 | 14 days ago | |
| levifig/rails-instructions.cursor/rules/guidelines.mdc · 54 | Cursor rules | teststyletesting-strategysecurity+4 | 71/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/levifig-rails-instructions-github-instructions-rails-security-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.