Payload Encryption
Categories:
Implementing Encrypted Payloads in FX Platform Services
In environments like the FX platform, where services exchange data over internal networks protected by TLS, there still exists a need for additional security measures. Specifically, there are scenarios where the confidentiality of certain payload parameters must be maintained, even from other developers within the platform.
To address this, encrypting specific attributes or entire data structures within payloads before transmission is a practical solution. This process relies on AES symmetric encryption, where both encryption and decryption are performed using the same secret key.
Steps for AES Symmetric Encryption
-
Key Generation: The first step involves generating a 16-byte (128-bit) AES key. This key size is chosen for its balance between security and computational efficiency.
-
Key Distribution: The AES key must then be securely shared with the receiving service(s). This step is crucial and requires secure methods of transmission to ensure that only authorized recipients have access to the key.
-
Agreement on Encryption Scope: The sending and receiving services need to agree on which data within the payload will be encrypted. This could include specific attributes or entire data structures, depending on the sensitivity of the information.
-
Encryption Process: Before sending data, the sending service encrypts the agreed-upon elements of the payload using the AES key. This step transforms the data into a format that is unreadable without the key.
-
Decryption by Recipient: Upon receiving the encrypted payload, the recipient service uses the AES key to decrypt the data. It is recommended that the key is stored securely, often as an environment variable or within a secure storage solution, to prevent unauthorized access.
AES Key Generation
You can use the following code snippet to generate an AES encryption key. Alternatively you can create one on websites such as
|
|
Encryption Key Storage
For enhanced security, both the sending and receiving services must adhere to stringent key management practices. Specifically, the AES key should be securely stored and retrieved from the FX secrets management system. Under no circumstances should the key be embedded directly in config.json
files or included within Git repositories. Storing keys in such locations significantly increases the risk of unauthorized access and potential data breaches.
Instead, leveraging dedicated secrets management tools ensures that the key remains encrypted and accessible only to authorized services and individuals, thereby maintaining the integrity and confidentiality of the encrypted payloads.
Payload Encryption and Decryption
The following snippet demostrates how you can decrypt strings or dicts.
|
|
Conclusion
Encrypting payloads or specific payload attributes with AES symmetric encryption provides an effective way to enhance data confidentiality in the FX platform’s service-to-service communications. This method ensures that sensitive information remains protected, even in environments where multiple developers have access to the platform.
By following the outlined steps and adhering to best practices for key management and encryption, services can maintain the integrity and confidentiality of their data exchanges.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.