Open, hosted federation using DomainKeys Identified Federation (DKIF)
Hi Guys,
We are working on a project which extends the current stellar federation standard/workflow in order to improve security and enable hosted federation without the need to trust the federation provider.
The extension is based on a simplified version of the well known and used standard DKIM (DomainKeys Identified Mail). It introduces signing of federation records and signature validation by the client. The solution is backwards compatible with the current workflow. Older clients can simply ignore the signature and newer clients which implement the new validation workflow can show a sign to the sender to verify that DKIF was used to resolve the federation andress.
Using this extension we would like to introduce a donation based, secure and open stellar federation service for Stellar community individuals and a hosted federation service for users and organizations who have their own domain but cannot, or do not want to, host their own federation server.
As this proposal would require a minor modification/extension of the current federation workflow, we would be very keen to hear the feedback of the Stellar developers together with the community members.
Current federation workflow
Currently, in order to resolve a federation address, the client needs to do the following:
1) fetch the stellar.toml file from https://<domain>/.well-known/stellar.toml and read the FEDERATION_SERVER entry from it
2) fetch the response from the federation server using secure HTTP GET and required parameters
3) proceed with the payment
Although it is mandatory to use HTTPS for both requests, both the web server and the federation server are possible targets for hackers. These servers are directly exposed to the internet and if a hacker manages to compromise either of them they could redirect the payments.
In case an attacker compromised the web server hosting the example.com site, they could rewrite the stellar.toml file pointing the FREDERATION_SERVER entry to their own host, serving wrong records and receiving all the payments. Compromising the federation server would allow the attacker to replace the public keys in each response, receiving all the payments.
Proposal: signing and validating the federation records
We would like to introduce the signing of the federation records using the workflow below. These signatures can be inspected and validated by the clients (“wallets” who are sending money to a destination address) before sending payments.
Preparation
We generate a domain signing key pair using Ed25519 (same algorithm that is used for other components ) for each domain. We keep the public key in a TXT record (same method as DKIM) in the DNS of the domain which looks like the following: federation._stellardomainkey IN TXT “<publickey>”.
The format of the public key matches exactly the format of a Stellar address, and the existing tools for creating a signing pair can be used.
We pre-sign the federation records (offline) and include the signatures into the DB together with the other entries. We will have one signature per federation entry which contains all the federation records (stellar_address, account_id, memo_type, memo).
We configure the federation server to include a signature entry into the JSON response which looks like the following (see DKIM for more info about fields): “signature”:”<base64signature>”
Workflow with the new clients
New clients that support DKIF would take the following steps to resolve a federation address and validate it’s signature:
1) fetch the stellar.toml file from https://<domain>/.well-known/stellar.toml and read the FEDERATION_SERVER entry from it
2) fetch the response from the federation server using HTTP GET and required parameters
3) try to fetch the public key from the federation._stellardomainkey.<domain> TXT record of the domain
4) If both of the public key and the signature from the federation response were missing then client proceeds with the payment without DKIF validation as it currently does
5) If only one of them was missing (public key or the signature in the federation response), it blocks the payment and warns the sender
6) If both public key and signature were found, but federation entries cannot be validated using the signature and the public key, it blocks the payment and warns the sender
7) If federation entries could be validated using the signature and the public key it proceeds with payment (and notes the sender that the resolution was using DKIF)
This workflow is compatible with existing clients and federation servers which do not implement signing/validation. Older federation servers would not return a signature field and older clients would just ignore the signatures (we assume that clients ignore additional fields in the JSON response from federation servers).
Benefits
When a federation service is using DKIF, taking over the web server which hosts the stellar.toml file and/or the federation server itself would not allow the attackers to redirect the payment. In order to do that, they would need to alter in addition the DNS response on the client side as well.
This allows (and requires) that the open federation providers sign the records offline and upload it to the federation database together with the records.
It also allows the introduction of federation hosting for people or organisations who have their own domains but do not want or cannot run their own federation server. These people can include their public key into their own DNS, sign the records with their private key, upload them together with the signatures to a federation hosting provider and point the FEDERATION_SERVER entry to the provider. With this solution there is no need to trust the federation provider as it would not be able to temper with the presigned records or signature.
UPDATE: we are live!
Finally, we went live with our Secure Open & Hosted Stellar Federation service.
The site is here: https://lumenbox.org
Please enjoy and provide your feedback. ?