Djed: Vulnerabilities Detected In Audit

Li₿ΞʁLiøη
5 min readFeb 2, 2023

--

Technical Review of Djed by Tweag.

Finally, and after having launched the Djed stablecoin on January 31 of this year, the audit report contracted by IOG, was published.

In a previous article, and some time before the launch of Djed, I published 6 critical points that I considered important on weaknesses for the launching: Djed: A Stablecoin in Cardano That Must Evolve.

One of those issues that I considered a problem was that the audit report that COTI had announced as completed was not published. Well, they did publish it a couple of days after the launch: Technical Review of Djed, and has an issue date of November 29, 2022.

Tweag is one of the most well-known and respected auditing companies in the Crypto Industry.

In this article I will mention the vulnerabilities, because my intention is to alert investors and the whole community about them, which ultimately are an investment risk.

It will never be my intention to create FUD or FOMO, neither in our Cardano Community or any other. I always seek the truth, with constructive criticism to evolve. The polite does not take away the brave.

I quote a brief summary of the severe vulnerabilities, but you can read the explanation of all the remaining ones in the published report.

The report is composed of two main sections of analysis:

  • Vulnerabilities: an attacker could exploit if the code were deployed as-is, including: race conditions or denial-of-service attacks blocking other users from using the contract, incorrect dust collection and arithmetic calculations (including due to overflow or underflow), incorrect minting, burning, locking, and allocation of tokens, authorization issues
  • Unclear Specification: unclear or wrong specifications that might allow for fringe behavior

Tweag clarifies about vulnerability list: “Table 2.3 lists our concerns with the current Djed implementation based on our partial exploration during a limited period of time

Vulnerabilities

Severity: High

  1. Additional tokens of the order token currency symbol can be minted

“When burning an order token, module Contracts.Request makes checks on the tokens with token name “DjedOrderTicket” to ensure no additional order tokens can be minted or burned. However, any other token name is unchecked. This entails that whenever an order token is burned (when it is canceled, processed, or when a successful complaint is issued), any number of tokens with the same minting policy but different token names can be minted and directed to any wallet.”

High

  1. Non-Djed tokens are not guaranteed to go back to order submitters
  2. Documentation comments and in-code comments are lacking
  3. There is no text in the specification for mintSC and mintRC

Medium

  1. Minting non-Djed tokens at the same time as an order token is impossible
  2. Requirements about sorting orders when processing them are inconsistent
  3. There are discrepancies regarding the positions of UTxOs in outputs
  4. Specification and implementation disagree on absence of stablecoin in input
  5. The documentation comment in the stablecoin contract is incorrect
  6. The onchain sorting algorithm for orders is costly
  7. The implementation of function processOrders lacks clarity

Low

  1. The oracle and stablecoin cannot be terminated simultaneously
  2. Part of the datum in the stable coin UTxO is redundant with the value
  3. Recursive operations are not implemented using a “fold” function
  4. Functions mintSC and mintRC have misleading names
  5. Interval variable names are confusing

Lowest

  1. Specification could be improved with visual representations
  2. Function validMinAdaTransfer uses Either against common usage
  3. There are inconsistent debug messages in reward fee contract
  4. Some documentation comments are not detailed enough

Unclear Specification

Severity: High

  1. Non-Djed tokens are not guaranteed to go back to order submitters

When submitting orders, it is possible to add extra tokens that are unrelated to the Djed protocol in order UTxOs.Documentation comments and in-code comments are lacking.

2. Documentation comments and in-code comments are lacking

Many helper and auxiliary functions used by the validators lack documentation comments (including general description and specification of each parameter). Sometimes in-code comments are missing as well, especially when dealing with long functions with disjoint cases or nested conditions. Many of these functions have no straightforward name or type signature that would be enough to reasonably infer their specification and the design choices taken in their implementation. Furthermore, some of these functions deal with critical aspects of Djed.

3. There is no text in the specification for mintSC and mintRC

When processing orders, the functions mintSC and mintRC are called to compute the resulting reserve state, i.e. how many stable coins and reserve coins are in circulation after processing, etc. They also are responsible for assessing if an order is invalid due to invalid reserve, insufficient ada, etc.

Severity: Medium

  1. Minting non-Djed tokens at the same time as an order token is impossible
  2. Requirements about sorting orders when processing them are inconsistent
  3. There are discrepancies regarding the positions of UTxOs in outputs
  4. Specification and implementation disagree on absence of stablecoin in input
  5. The documentation comment in the stablecoin contract is incorrect

Severity: Low

  1. The oracle and stablecoin cannot be terminated simultaneously

Severity: Lowest

  1. Specification could be improved with visual representations

Final Words

In the report’s conclusion, Tweag states: “This report outlines the 20 concerns that we have gathered while inspecting the design and code of Djed, pertaining to the code contained in the files listed in Table 2.1. As stated in Chapter 1, Tweag does not recommend for nor against the use of any work referenced in this report. Nevertheless, the existence of high severity concerns is a warning sign.”

The Appendix of the report cites: “IOG has conducted their own analysis of Djed. This section describes and comments on their findings and the updates they have applied accordingly.

And then, Tweag clarifies: “The present appendix is not the result of any new auditing work by Tweag on Djed. No significant code analysis nor tests have been performed on the new version of the product. Hence, the comments this appendix contains are merely high level thoughts gathered after discussing and acknowledging changes made by IOG, based on our knowledge of the version of Djed we audited back in November 2022. Although unlikely, their is no guarantee that these changes have not altered the result of the previous audit, nor introduced additional weaknesses.

Software development companies hire audits to look for vulnerabilities in their design in order to fix them, and they have found 20 concerns. After 2 months of concluding the audit they have released the stablecoin, but have they fixed all the vulnerabilities in this time?

--

--

Li₿ΞʁLiøη
Li₿ΞʁLiøη

Written by Li₿ΞʁLiøη

Researcher • Ϛʁyptø_Writer • Content Creator | 𝕏 @liberlion17 | nostr liberlion@iris.to | website: liberlion.com

No responses yet