framework_eng/skills/bsl-practices/security/SKILL.md
MUST use WHEN working with passwords, tokens, electronic signatures, TLS, or privileged mode in 1C code. Provides rules for storing secrets in `БезопасноеХранилище`, cryptography (GOST/`МенеджерКриптографии`) and authentication.
npx skillsauth add steelmorgan/1c-agent-based-dev-framework securityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill is a topic map for security in 1C application code. Platform API specifics are moved into references/. Here are the trust boundaries, common mistakes, and stop rules that every agent (architect / developer-code / reviewer) must follow when working with sensitive data.
Security in 1C is not a separate subsystem, but an end-to-end property of code:
БезопасноеХранилище, not in code/configuration/logs.МенеджерКриптографии + an explicit provider (CryptoPro CSP / ViPNet) with an explicit GOST version.| Trigger | Action |
|---------|----------|
| You see work with a password/token/secret in a procedure parameter or in a code string | Read references/secrets.md, move it to БезопасноеХранилище, check masking in logs |
| You see work with МенеджерКриптографии, СертификатКриптографии, ХранилищеСертификатовКриптографии, ПараметрыПодписиCMS | Read references/crypto.md, check the provider, GOST version, context (client/server), and private key lifecycle |
| You see an HTTP call to an external API, OpenID/OAuth, basic-auth, or a client TLS certificate | Read references/auth.md, check error semantics and credential storage |
| You are reviewing code that touches rights, RLS, privileged mode, or external integrations | Use references/review-checklist.md as a mandatory filter before the final answer |
| You need to design a new integration/service with authentication | First define the trust boundary (see below), then choose the API |
Before you write or review code, explicitly define which boundary it crosses:
HTTPСоединение, OpenID/OAuth, client certificate, TLS.МенеджерКриптографии, CryptoPro CSP / ViPNet, access to the certificate store under the rphost/srv1cv8 account.БезопасноеХранилище, or an external vault through a connector.If the boundary is not named, the skill is being applied incorrectly: go back to the design stage.
БезопасноеХранилище → references/secrets.mdБезопасноеХранилище.УстановитьДанные(Владелец, Данные[, Ключ]) and ПрочитатьДанные(Владелец[, Ключ]).УстановитьПривилегированныйРежим(Истина) in a targeted way (not for the whole module).references/crypto.mdМенеджерКриптографии(ИмяПровайдера, ТипПровайдера) - the provider is selected explicitly (CryptoPro CSP, ViPNet CSP).СертификатКриптографии, ХранилищеСертификатовКриптографии, ПараметрыПодписиCMS.Хранилище.Значение.ЭлектроннаяПодпись, ЭлектроннаяПодписьСлужебный) - the preferred path if БСП is present in the configuration.references/auth.mdИнтернетПользователи).HTTPСоединение/HTTPЗапрос, the token and refresh token are stored in БезопасноеХранилище.БезопасноеХранилище, header assembled on the server.СертификатКлиентаФайл, СертификатКлиентаWindows, СертификатКлиентаOpenSSL in HTTPСоединение.missing credentials, expired token, invalid certificate, provider unavailable, denied rights, tenant mismatch, remote auth failure.references/review-checklist.mdA stack-neutral checklist that the reviewer agent must pass before the final answer whenever the code touches any of the topics above.
These rules are strict. A violation means a blocking review comment and a code rewrite.
A password/token/private key must not be passed through a procedure parameter that crosses the "client ↔ server" boundary
Server, Server Call and a Пароль parameter.A private key / cryptography container is not stored in a common module, catalog attribute, or constant
Константа.КлючШифрования, or in a template.МенеджерКриптографии.УстановитьПривилегированныйРежим(Истина) around БезопасноеХранилище access is mandatory and targeted
УстановитьПривилегированныйРежим, БезопасноеХранилище.ПрочитатьДанные will fail on permissions for a regular user.УстановитьПривилегированныйРежим(Ложь) must be set immediately after reading, in the same Попытка/Исключение block.Logs and the registration log do not contain tokens, passwords, private keys, or full Authorization headers
ЗаписьЖурналаРегистрации, Сообщить, and the agent response - only masked values (***, last 4 characters, certificate fingerprint).An authentication error is different from a validation error and a business error
401/403 from an external API does not become "failed to perform the operation". It is a separate error type with separate handling (refresh, re-login, escalation).Context: You need to call an external REST API with OAuth 2.0 (client credentials).
Steps:
client_secret and refresh_token - in БезопасноеХранилище, owner = reference to the catalog item.УстановитьПривилегированныйРежим, in a targeted way.Authorization header on the server; do not return the header to the client.expired token → refresh, invalid client → configuration error (no retry), provider unavailable → retry with backoff.client_id - plain, client_secret/access_token - masked (last 4 characters).references/review-checklist.md.Context: You need to sign XML/PDF with a qualified digital signature according to GOST R 34.10-2012.
Steps:
МенеджерКриптографии manually.МенеджерКриптографии("Crypto-Pro GOST R 34.10-2012 Cryptographic Service Provider", 80) with an explicit ТипПровайдера.Отпечаток), not by "the first suitable one".ПараметрыПодписиCMS (detached/attached, encoding).ДанныеПодписи in full; log the certificate Отпечаток and the business object identifier.Context: УстановитьПривилегированныйРежим(Истина) appeared in a PR.
Steps:
УстановитьПривилегированныйРежим(Ложь) in the same scope and inside Попытка/Исключение.references/review-checklist.md.// Сервер. Чтение токена внешнего API из безопасного хранилища.
// Привилегированный режим — точечный, только вокруг чтения секрета.
Функция ПолучитьТокенДоступа(УчётнаяЗапись) Экспорт
УстановитьПривилегированныйРежим(Истина);
Попытка
ДанныеСекрета = БезопасноеХранилище.ПрочитатьДанные(УчётнаяЗапись, "access_token");
Исключение
УстановитьПривилегированныйРежим(Ложь);
ВызватьИсключение;
КонецПопытки;
УстановитьПривилегированныйРежим(Ложь);
Если ДанныеСекрета = Неопределено Тогда
ВызватьИсключение НСтр("ru = 'Токен не настроен для учётной записи.'");
КонецЕсли;
Возврат ДанныеСекрета;
КонецФункции
// АНТИПАТТЕРН: пароль пересекает границу клиент/сервер в открытом параметре.
// АНТИПАТТЕРН: пароль попадает в журнал регистрации.
&НаСервереБезКонтекста
Функция ОтправитьДокумент(URL, Логин, Пароль, ТелоЗапроса) Экспорт
ЗаписьЖурналаРегистрации("Интеграция",
УровеньЖурналаРегистрации.Информация,
,
,
"Отправка: URL=" + URL + ", Логин=" + Логин + ", Пароль=" + Пароль);
// ... вызов внешнего API ...
КонецФункции
| Mistake | Consequence | How to avoid |
|--------|-------------|--------------|
| Password/token in the parameter of an exported server procedure | Leak over the network, in dumps, in client logs | Pass only the secret owner (reference), read the secret on the server |
| УстановитьПривилегированныйРежим(Истина) for the whole module/function | Bypasses RLS and role checks across all business logic | A targeted block only around БезопасноеХранилище access |
| Storing access_token in a catalog attribute / constant / template | Any user with read access to the catalog gets the token | БезопасноеХранилище + owner = reference to the catalog item |
| МенеджерКриптографии() without an explicit provider and type | The code works in one environment and fails in production with another provider | Explicit ИмяПровайдера + ТипПровайдера, GOST version fixed |
| Certificate chosen as "the first one in the store" | Signature with the wrong certificate during rotation | Search strictly by Отпечаток |
| 401 from an external API → Сообщить("Ошибка при сохранении") | Impossible to distinguish an expired token from a data error | Separate authentication error type + refresh handling |
| Logging the entire HTTP request/response body | Passwords/tokens/PII end up in the registration log | Sanitize before logging, mask sensitive fields |
error-handling - the general error model, including distinguishing technical and business errors.integration-patterns - patterns for HTTP services and external integrations that authentication is attached to.ssl-patterns - БСП modules (including "Electronic Signature", "ИнтернетПользователи").coding-standards - general rules for formatting server-side code.testing
MUST use BEFORE making a judgment about the cause of a conflict, a test failure, or an artifact dispute. Defines the end-to-end verification method L1→L6 and the classification of the first broken link.
development
MUST use AFTER a work cycle with ≥2 iterations (wrote → error → fixed → success). Provides the retrospective procedure and the format for recording practice/anti-patterns in references/learned-patterns.md or {project}/.context/learned-patterns.md.
tools
MUST use WHEN you are writing reusable knowledge into RLM (pattern / architectural decision / stable domain fact) OR reading it before a non-trivial task/solution in the domain. Provides the breakdown of native-push vs RLM-pull, tools for writing and reading RLM, H-MEM levels, and hygiene.
testing
MUST use WHEN the task is classified as simple (< 20 lines, 1 file, no new metadata objects, no architectural decisions). Provides a short cycle of 3 steps with a guard on the self path and mandatory verify.