# Security tips for Chromia dapps · Chromia Docs (concept)

> Implement delayed configuration updates to provide users with advance notice of changes and prevent sudden malicious modifications:

Source: https://docs.chromia.com/rell/security/

# Security tips for Chromia dapps

On this page

* [Protection against malicious dapps](#protection-against-malicious-dapps)
* [Delayed configuration updates](#delayed-configuration-updates)
* [Governance implementation](#governance-implementation)
* [Protection against malicious users](#protection-against-malicious-users)
* [Rate limiting](#rate-limiting)
* [Use require functions](#use-require-functions)

## Protection against malicious dapps

### [Delayed configuration updates](https://docs.chromia.com/ecosystem/providers/nodes/directory-chain-config/#delayed-blockchain-configuration)

Implement delayed configuration updates to provide users with advance notice of changes and prevent sudden malicious
modifications:

YAML

```
blockchains:
  <my_blockchain_name>:
    config:
      directory_chain:
        config_delay: 86400000 # 24 hours delay in milliseconds
```

This delay period allows:

* Users to review and prepare for upcoming changes
* Detection and prevention of malicious configuration updates
* Time for governance participants to react to suspicious changes

### Governance implementation

Implement a robust governance system to manage dapp updates and configurations.

[Governance starter kit](https://docs.chromia.com/ecosystem/governance/getting-started/governance-starter-kit/overview/) can be seamlessly
integrated into the dapp, offering flexibility and speeding up the prototyping process while maintaining compatibility
with the core governance system. The plug-and-play approach allows developers to quickly implement standardized
governance features without extensive refactoring, reducing development time while ensuring security best practices.

#### Proposal management

[Governance proposals](https://docs.chromia.com/ecosystem/governance/getting-started/governance-starter-kit/import/) enable users to suggest and
vote on dapp changes. This ensures that the dapp evolves through transparent, collective decision-making rather than
unilateral control. This participatory model protects users by decentralizing authority, reducing the risk of malicious
upgrades or hidden backdoors.

YAML

```
blockchains:
  <my_blockchain_name>:
    module: <my_module_name>
    moduleArgs:
      lib.governance.proposals:
        proposal_configs:
          option_item_limit: 10 # maximum number of choices per proposal
          max_duration: 2592000000000 # 30 days
          min_duration: 3600000 # 1 hour
```

For more details, refer to the
[docs](https://docs.chromia.com/ecosystem/governance/getting-started/governance-starter-kit/import/#proposal-and-voting-configuration) and the
[Repo with the dapp example](https://bitbucket.org/chromawallet/governance-starter-kit/src/production/rell/).

#### Veto system

The veto mechanism serves as a safeguard, allowing trusted governance entities or thresholds to block harmful or rushed
proposals before they are executed. This enhances user security by preventing governance attacks or mistakes that could
compromise user assets or dapp functionality.

YAML

```
blockchains:
  <my_blockchain_name>:
    module: <my_module_name>
    moduleArgs:
      lib.governance.votes:
        veto_config:
          veto_period: 100000 # Veto period in milliseconds
```

See the [Repo](https://bitbucket.org/chromawallet/governance-starter-kit/src/production/rell/) for additional
information.

## Protection against malicious users

### Rate limiting

Implementing [rate limiting](https://docs.chromia.com/ecosystem/governance/getting-started/governance-starter-kit/import/#accounts-configuration)
with `points_at_account_creation` ensures that a user can only perform a limited number of operations (usually one)
within a specified timeframe, with the wait time controlled by `recovery_time`.

YAML

```
blockchains:
  <my_blockchain_name>:
    module: <my_module_name>
    moduleArgs:
      lib.ft4.core.accounts:
        rate_limit:
          active: true
          max_points: 10
          recovery_time: 5000
          points_at_account_creation: 1
```

Refer to the [Repo](https://bitbucket.org/chromawallet/governance-starter-kit/src/production/rell/) for additional
details.

### Use require functions

The [require](https://docs.chromia.com/rell/language-features/systemlib/require-function/) function serves as a validation mechanism that helps
check input parameters against business rules. If the condition provided to
[`require`](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/require/) is not met, the function
aborts execution and raises an error.

Rell

```
operation transfer(from: account, to: account, asset, amount: big_integer) {
      require (from != to, "Sender and receiver have to be different");
      require (amount > 0, "Transfer amount must be positive");
      ...
   }
```

[View this page on docs.chromia.com](https://docs.chromia.com/rell/security/)Content mirrored from the live docs
