A bad price can be delivered in ChainlinkARBOracle
When the `consultIn18Decimals()` is called, can be returned a negative value. Because not exist correct validation for negative response.\\nThe `ChainlinkARBOracle.sol` has to garantie delivered correct price. Howerver exist a potencial scenario of this situation may be breaking.\\nLets break each one part of this scenario:\\nWhen `consultIn18Decimals()` is called, and call to `consult()` this function is encharge `of` verifie each answer and delivere a price not old, not zero,non-negative and garantie `of` sequencer is up.\\nPosible scenario in `consult()` for the moment, we have: `chainlinkResponse.answer = x where x > 0` `prevChainlinkResponse.answer = y where y < 0` This is a negative value given by Chainlink\\n`_chainlinkIsFrozen()` is pass correctly\\n`_chainlinkIsBroken(chainlinkResponse, prevChainlinkResponse, token)` evaluate the following functions:\\n`_badChainlinkResponse(currentResponse)` pass correctly.\\n`_badChainlinkResponse(prevResponse)` pass also correctly because is only check if the value is zero, but not negative see : `if (response.answer == 0) { return true; }`\\n_badPriceDeviation(currentResponse, prevResponse, token): `if( currentResponse.answer > prevResponse.answer)` remember `currentResponse.answer = x where x > 0 and prevResponse.answer = y where y < 0` So. x > y . This condition is passed successfully..\\nFor the evaluation `of` `_deviation` we have: `_deviation = uint256(currentResponse.answer - prevResponse.answer) * SAFE_MULTIPLIER / uint256(prevResponse.answer); The result will always return zero. So validation on` _badPriceDeviationof_deviation > maxDeviations[token]always returnsfalsebecause zero can never be greater for any number ofmaxDeviations[token]since it only accepts numbers `of` typeuint256 `\\nPOC :\\nThis scenario is illustrated in a minimalist example, which you can use in Remix:\\n```\\n// SPDX-License-Identifier: UNLICENSED\\npragma solidity 0.8.21;\\n\\nimport { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";\\n\\nerror BrokenTokenPriceFeed();\\n\\ncontract PassWithNegativePrice {\\n\\n    using SafeCast for int256;\\n\\n    uint256 public maxDeviations;\\n    int256 public currentResponse;\\n    int256 public prevResponse;\\n    uint8 public decimal;\\n    \\n    constructor(int256 _currentResponse, int256 _prevResponse, uint8 _decimal,uint256 _maxDeviation )  {\\n        currentResponse = _currentResponse; //  _currentResponse > 0 e.g. 2000, 3, 90000000000000\\n        prevResponse = _prevResponse; // _prevResponse < 0  e.g. -3000, -1 \\n        decimal = _decimal; // _decimal can be 8, 18\\n        maxDeviations = _maxDeviation; // any value\\n    } \\n    \\n    // You call this function,  result is currentResponse but doesn't matter  maxDeviations value\\n    function consultIn18Decimals() external view  returns (uint256) {\\n    \\n        (int256 _answer, uint8 _decimals) =  consult();\\n\\n        return _answer.toUint256() * 1e18 / (10 ** _decimals);\\n    }\\n\\n    function consult() internal view  returns (int256, uint8) { \\n\\n        if (_badPriceDeviation(currentResponse, prevResponse) )revert  BrokenTokenPriceFeed();\\n\\n        return (currentResponse, decimal);\\n    }\\n\\n    function _badPriceDeviation(int256 _currentResponse, int256 _prevResponse ) internal view returns (bool) {\\n    // Check for a deviation that is too large\\n        uint256 _deviation;\\n\\n        if (_currentResponse > _prevResponse) { // Here is our scene, always result be zero with negative value of _prevResponse\\n        _deviation = uint256(_currentResponse - _prevResponse) * 1e18 / uint256(_prevResponse);\\n        } else {\\n        _deviation = uint256(_prevResponse - _currentResponse) * 1e18 / uint256(_prevResponse);\\n        }\\n\\n        return _deviation > maxDeviations;\\n    }\\n\\n\\n}\\n```\\n
This behavior can be mitigated by setting the correct conditional:\\n```\\nif (response.answer <= 0) { return true; }\\n```\\n\\nAlso,due of only consultIn18Decimals() is the function that is called for the protocol. Visibility to "consult" may be restricted. Change from "public" to "internal".
High, the base protocol is how you get the price of the securities. The answer may be different than what is allowed. Because the maximum deviations will not be counted.
```\\n// SPDX-License-Identifier: UNLICENSED\\npragma solidity 0.8.21;\\n\\nimport { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";\\n\\nerror BrokenTokenPriceFeed();\\n\\ncontract PassWithNegativePrice {\\n\\n    using SafeCast for int256;\\n\\n    uint256 public maxDeviations;\\n    int256 public currentResponse;\\n    int256 public prevResponse;\\n    uint8 public decimal;\\n    \\n    constructor(int256 _currentResponse, int256 _prevResponse, uint8 _decimal,uint256 _maxDeviation )  {\\n        currentResponse = _currentResponse; //  _currentResponse > 0 e.g. 2000, 3, 90000000000000\\n        prevResponse = _prevResponse; // _prevResponse < 0  e.g. -3000, -1 \\n        decimal = _decimal; // _decimal can be 8, 18\\n        maxDeviations = _maxDeviation; // any value\\n    } \\n    \\n    // You call this function,  result is currentResponse but doesn't matter  maxDeviations value\\n    function consultIn18Decimals() external view  returns (uint256) {\\n    \\n        (int256 _answer, uint8 _decimals) =  consult();\\n\\n        return _answer.toUint256() * 1e18 / (10 ** _decimals);\\n    }\\n\\n    function consult() internal view  returns (int256, uint8) { \\n\\n        if (_badPriceDeviation(currentResponse, prevResponse) )revert  BrokenTokenPriceFeed();\\n\\n        return (currentResponse, decimal);\\n    }\\n\\n    function _badPriceDeviation(int256 _currentResponse, int256 _prevResponse ) internal view returns (bool) {\\n    // Check for a deviation that is too large\\n        uint256 _deviation;\\n\\n        if (_currentResponse > _prevResponse) { // Here is our scene, always result be zero with negative value of _prevResponse\\n        _deviation = uint256(_currentResponse - _prevResponse) * 1e18 / uint256(_prevResponse);\\n        } else {\\n        _deviation = uint256(_prevResponse - _currentResponse) * 1e18 / uint256(_prevResponse);\\n        }\\n\\n        return _deviation > maxDeviations;\\n    }\\n\\n\\n}\\n```\\n