Secure Properties Using Mule4

When developing MuleSoft applications, safeguarding sensitive information such as passwords, API keys, and database credentials is crucial to protect your application from potential security threats. This blog will guide you through the best practices and techniques for securely managing properties in MuleSoft.
Why Secure Properties?
Storing sensitive information directly in configuration files can lead to security vulnerabilities. If unauthorized individuals access these files, they may gain access to critical systems or data. Properly securing properties ensures compliance with security standards and helps maintain the integrity of your applications.
Techniques for Securing Properties in MuleSoft
1. Secure Property Placeholder (secure-properties-tool
)
The Secure Property Placeholder module encrypts sensitive properties stored in configuration files, making them unreadable without the appropriate decryption key.
Steps to Use Secure Property Placeholder:
- Install the Secure Properties Tool: Download the
secure-properties-tool.jar
from MuleSoft. - Access Properties in Mule Flows:
Configure Secure Property Placeholder: Add the configuration in global.xml
:
<secure-properties:config name="Secure_Properties" doc:name="Secure Properties">
<secure-properties:encrypt-key>mySecretKey</secure-properties:encrypt-key>
</secure-properties:config>
Store Encrypted Properties: Create a properties file (config-secured.properties
) with the encrypted values:
db.password=ENC(ENC_VALUE_HERE)
Encrypt Properties: Run the following command to encrypt sensitive values:
java -cp secure-properties-tool.jar com.mulesoft.tools.SecurePropertiesTool \
encrypt -k mySecretKey -v "MySensitivePassword"

Copy the generated db-secure-dev.yaml into src/main/resources, edit the Database Config as shown

Run the application and observe if it still works same.
<configuration-properties doc:name="Configuration properties" doc:id="939739f1-02cc-4494-9174-e1bac975c70a" file="name-db.yaml" />
<db:config name="Database_Config" doc:name="Database Config" doc:id="7ca8be2a-b438-497f-9490-67180ca2b9c7" >
<db:my-sql-connection host="${secure::db.host}" port="${secure::db.port}" user="${secure::db.username}" database="${secure::db.dbname}" password="${secure::db.password}"/>
</db:config>
<secure-properties:config name="Secure_Properties_Config" doc:name="Secure Properties Config" doc:id="2de5364a-c147-4269-adfb-e3fa528c8e35" file="db-secure-dev.yaml" key="abcdefghijklmnop" >
<secure-properties:encrypt algorithm="Blowfish" />
</secure-properties:config>
Method 2: Securing Properties using Secure Properties Generator
MuleSoft has optimized the complete process by providing an online secure properties generator that gives developers ease of securing properties. MuleSoft developers can now secure the properties in a point and click environment eliminating the command line interface.
The secure properties generator gives us an option of directly encrypting our values without creating an input file. However, we can secure our properties using input files as well.

Provide the following configurations.

Choose the operation type.

Select the Algorithm type.

Choose the required State.

Provide the Special key.

While choosing AES algorithm, you have to provide key of length 16.
While choosing Blowfish algorithm, you have to provide key of length 15
Fill in the Value you want to Encrypt.

Click on Generate to get the required Result.

You can also provide the encrypted result along with the key (previously used for encryption) to get the Original Value.

Securing properties is one of the essential elements in every Mule project, and MuleSoft has made this process far easier for a developer by introducing Secure Properties Generator.
Best Practices for Securing Properties
- Do Not Hardcode Sensitive Information: Always use secure placeholders or external property files.
- Encrypt Properties: Ensure sensitive data is encrypted both at rest and in transit.
- Environment Variables: Manage secrets using environment variables instead of embedding them in files.
- Access Control: Restrict access to property files and secrets to authorized personnel.
- Audit and Rotate Keys: Regularly audit key usage and rotate keys periodically.
Conclusion
Securing properties in MuleSoft is essential for building robust, secure applications. By using techniques like the Secure Property Placeholder, configuration properties, and Anypoint Secrets Manager, you can protect your sensitive information and maintain high-security standards. Implement these strategies and best practices to ensure your MuleSoft applications are safe and secure.