-
Notifications
You must be signed in to change notification settings - Fork 0
Fix security vulnerabilities, dependency conflicts, and slippage protection #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Deployment failed with the following error: Learn More: https://vercel.link/mix-routing-props |
Co-authored-by: MastaTrill <119138354+MastaTrill@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
aetheron | 2da30c2 | Jan 12 2026, 02:10 AM |
- Remove unused dependencies from root package.json (web3, react, express, etc) - Fix all 55 vulnerabilities (2 critical, 4 high, 5 moderate, 44 low) in root dependencies - Add missing peer dependencies for mobile app (@react-native-community/netinfo, react-native-get-random-values) - Add .npmrc with legacy-peer-deps flag to mobile app to allow installation - All packages now install successfully with 0 vulnerabilities References: Security audit findings Co-authored-by: MastaTrill <119138354+MastaTrill@users.noreply.github.com>
- Update .gitignore to exclude .env files, build outputs, and IDE files - Remove tracked .env file from git history (contained no secrets) - Fix TODO: Implement proper slippage protection in mobile app SwapScreen - Calculate amountOutMin from quote.minReceived instead of using 0 - Fix tsconfig.json by removing invalid ignoreDeprecations option - Mobile app now properly validates minimum received amount on swaps References: Security best practices, slippage protection Co-authored-by: MastaTrill <119138354+MastaTrill@users.noreply.github.com>
- Remove fallback to 0 for amountOutMin in swap execution - Throw error if quote.minReceived is not available - Ensures swap always has slippage protection References: Code review feedback Co-authored-by: MastaTrill <119138354+MastaTrill@users.noreply.github.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request addresses security vulnerabilities, dependency conflicts, and implements critical slippage protection in the mobile swap functionality. The changes remove unused dependencies from the root package, fix peer dependency issues in the mobile app, correct TypeScript configuration errors, and most importantly, add slippage protection to prevent users from being exploited by sandwich attacks.
Changes:
- Removed all unused dependencies from root package.json (web3, express, react, hardhat, etc.)
- Added missing peer dependencies (@react-native-community/netinfo, react-native-get-random-values) and .npmrc configuration for React Native 0.73.5 compatibility
- Implemented slippage protection in SwapScreen.tsx by calculating and enforcing amountOutMin based on quote.minReceived
Reviewed changes
Copilot reviewed 6 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Removed all unused dependencies from root workspace to eliminate security vulnerabilities |
| smart-contract/package-lock.json | Updated hardhat and related dependencies to latest patch versions (2.28.2→2.28.3, edr 0.12.0-next.21→22) |
| mobile-app/package.json | Added @react-native-community/netinfo and react-native-get-random-values to resolve peer dependencies |
| mobile-app/package-lock.json | Updated dependency tree with new packages and version consolidations, including ws major version update |
| mobile-app/tsconfig.json | Removed invalid ignoreDeprecations compiler option |
| mobile-app/src/screens/SwapScreen.tsx | Added slippage protection by calculating amountOutMin from quote.minReceived instead of hardcoded 0 |
| mobile-app/.npmrc | Added legacy-peer-deps=true to handle React Native 0.73.5 peer dependency conflicts |
| .gitignore | Enhanced to exclude .env files, build outputs, IDE files, and OS-specific files |
| .env | Removed tracked environment file (contained no secrets) |
Files not reviewed (2)
- mobile-app/package-lock.json: Language not supported
- smart-contract/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const deadline = Math.floor(Date.now() / 1000) + 60 * 10; | ||
| // TODO: Calculate amountOutMin using slippage | ||
| // Calculate amountOutMin using slippage from quote | ||
| if (!quote.minReceived) { |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check !quote.minReceived will return true for empty strings, but also for the string '0'. If the quote legitimately calculates to zero minimum received tokens (which could happen with very small amounts or extreme slippage), this would incorrectly throw an error instead of warning the user that the swap would result in receiving zero tokens. Consider checking for empty string explicitly or adding validation that the minReceived value is greater than zero with a more descriptive error message.
| if (!quote.minReceived) { | |
| if (quote.minReceived == null || quote.minReceived === '') { |
| if (!quote.minReceived) { | ||
| throw new Error('Unable to calculate minimum received amount. Please try again.'); | ||
| } | ||
| const amountOutMin = ethers.parseUnits(quote.minReceived, toToken.decimals); |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minReceived value from the quote is a string representation of a decimal number. When passing it to ethers.parseUnits, ensure that toToken.decimals accurately reflects the token's decimal places. If toToken.decimals is incorrect or undefined, this will result in an incorrect amountOutMin value being calculated, potentially exposing users to receiving far fewer tokens than expected or causing the transaction to fail.
| const amountOutMin = ethers.parseUnits(quote.minReceived, toToken.decimals); | |
| if (toToken.decimals === undefined || toToken.decimals === null || !Number.isFinite(Number(toToken.decimals))) { | |
| throw new Error('Token decimal information is unavailable. Please try again later or select a different token.'); | |
| } | |
| const amountOutMin = ethers.parseUnits(quote.minReceived, Number(toToken.decimals)); |
…p slippage, update dependencies Co-authored-by: MastaTrill <119138354+MastaTrill@users.noreply.github.com>
User description
Resolved all open security and code quality issues in the repository, including 55 npm vulnerabilities (2 critical, 4 high) and a critical trading vulnerability in the mobile swap functionality.
Security Vulnerabilities
Root package: Removed unused dependencies causing vulnerabilities
web3@1.10.0(critical form-data CVE),express,react,hardhat, and other unused packagesMobile app: Fixed peer dependency conflicts blocking installation
@react-native-community/netinfoandreact-native-get-random-values.npmrcwithlegacy-peer-deps=truefor React Native 0.73.5 compatibilityTrading Vulnerability
Fixed missing slippage protection in
SwapScreen.tsxthat exposed users to sandwich attacks:Configuration
.gitignoreto exclude.env, build outputs, and IDE files.envfile (contained no secrets but shouldn't be versioned)tsconfig.jsoncompilation error (invalidignoreDeprecationsoption)Verification
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
PR Type
Bug fix, Enhancement
Description
Removed 55 npm vulnerabilities by eliminating unused root dependencies
Fixed critical trading vulnerability with missing slippage protection
Added missing peer dependencies for mobile app React Native compatibility
Enhanced configuration with proper .gitignore and tsconfig.json fixes
Diagram Walkthrough
File Walkthrough
package.json
Remove unused dependencies and vulnerabilitiespackage.json
etc.)
low)
package.json
Add missing peer dependencies for mobile appmobile-app/package.json
@react-native-community/netinfov11.0.0 dependencyreact-native-get-random-valuesv1.10.0 dependencycompatibility
.npmrc
Add npm configuration for peer dependenciesmobile-app/.npmrc
legacy-peer-deps=trueto allow installation with peer dependencyconflicts
.env
Remove environment file from version control.env
SwapScreen.tsx
Implement slippage protection in swap executionmobile-app/src/screens/SwapScreen.tsx
0amountOutMin with calculated value from quotequote.minReceivedexists before swapexecution
tokens for ETH, tokens for tokens)
tsconfig.json
Remove invalid TypeScript compiler optionmobile-app/tsconfig.json
ignoreDeprecationsoption that caused compilationerrors