How GitHub converts previously encrypted and unencrypted columns to ActiveRecord encrypted columns
GitHub migrated plaintext columns and columns encrypted with a deprecated internal library to ActiveRecord::Encryption. It used per-model previous encryptors instead of the global support_unencrypted_data option, and a custom ActiveModel type gated by an inverted, long-lived feature flag that acts as an on/off switch for each column. A changed_in_place? bug compared decrypted plaintext to stored ciphertext, which raised false 2FA recovery-code alerts in customer security logs; delegating the check to EncryptedAttributeType fixed it. A simplified recipe using a previous encryptor plus the MaintenanceTasks gem backfills existing records, and the same flow handles key rotation by adding a new key and re-running the task.
Related posts
- Why and how GitHub encrypts sensitive database columns using ActiveRecord::Encryption
GitHub Engineering mediumAdeptGitHub replaced its internal Encrypted Attributes library with Rails' ActiveRecord::Encryption so developers can encrypt a sensitive column with a single familiar `encrypts` call, without hand-provisioning a key per column. The customizations are a custom key provider that pulls a single primary key from HashiCorp Vault and derives per-column keys with a KDF. The salt is table_attribute, and the current year goes in the info parameter so keys rotate yearly and limit AES-256-GCM nonce-reuse risk. An overridden `encrypts` helper makes this provider the default, and compression is disabled by default because compressing before encryption leaks plaintext entropy.
- Making Open Source Safer for Everyone with Shopify’s Bug Bounty Program
Shopify Engineering mediumAdeptA Shopify bug bounty report showed that a leaked Rails development secret could be escalated to remote code execution because ActiveSupport's MessageEncryptor deserialized data with Marshal by default. Shopify patched its app to use JSON serialization, then contributed Rails changes making JSON the default serializer for MessageEncryptor and MessageVerifier starting in 7.1, with an upgrade path for existing apps. It also shares a patch that hooks Marshal.load and Marshal.dump in development and CI to flag unexpected calls from gems, tracking and deprecating Marshal use across an application.
- How GitHub uses CodeQL to secure GitHub
GitHub Engineering mediumAdeptGitHub's Product Security Engineering team runs CodeQL across more than 10,000 repositories, mostly with default setup and the security-extended suites. Its Ruby monolith gets advanced setup with a custom query pack published to GitHub Container Registry. Publishing the pack separately avoided production deploys for every query change, gave precompiled queries, and kept CodeQL CLI upgrades from breaking monolith CI. A bad query could be rolled back by republishing the pack in under 15 minutes. The post shows how they pin the ruby-all dependency via codeql-pack.lock.yml, unit-test queries, share the pack through a linked repository, and use recommendation-severity custom queries (e.g. missing control_access on REST endpoints, ActiveRecord decrypt) alongside multi-repository variant analysis for bug bounty follow-up.
- Security Disclosure Recommendation: Rotate MySQL Database Credentials
Railway mediumAdeptRailway MySQL users whose password or MYSQL_URL may have been exposed should rotate the credential with the Regenerate button in the Database View. It changes the password inside MySQL, updates the template's dependent variables, and restarts the database, which drops all existing sessions. Every consuming service then needs a redeploy, because containers read variables only at startup. Pasted connection strings should be replaced with reference variables, and external MYSQL_PUBLIC_URL users must be updated by hand. Editing variables or running ALTER USER manually leaves the database and its variables out of sync. Verification and misuse checks cover deploy logs, information_schema.processlist, mysql.user grants, audit logs, table UPDATE_TIME, and point-in-time recovery.
- Track Schema Changes Automatically in Your Pull Requests
Neon mediumAdept
Neon's Schema Diff GitHub Action compares the schema of a pull request's Neon child branch against its parent (or a specified base_branch) and posts the result as an SQL patch in a single PR comment. The comment is edited in place on new commits, and nothing is posted when the schemas match. A sample workflow creates a per-PR Neon branch with create-branch-action, runs migrations against it, posts the diff, and deletes the branch when the PR closes. The action also outputs a comment_url for further automation, such as Slack notifications.