Unprotected Ether Withdrawal (SWC-105)

Description
To mitigate this vulnerability, it is important to implement proper access controls in the smart contract. Access controls should be used to restrict which functions can be called and by whom. It is also important to avoid exposing initialization functions, and to make sure that constructor functions are properly named to prevent them from being callable after deployment.
In addition, it is important to perform thorough testing and auditing of the smart contract code to identify and address any potential vulnerabilities before deployment. It is also recommended to use standardized security tools and frameworks to ensure that the smart contract code is secure and reliable.
Восстановление
To mitigate the risk of unauthorized withdrawals, it is important to implement access controls that ensure withdrawals can only be triggered by authorized parties or according to the specifications of the smart contract system. This can be achieved by using techniques such as role-based access control, whitelisting, and multi-factor authentication.
It is also important to thoroughly test the access control mechanisms to ensure they work as intended and cannot be circumvented by attackers. Additionally, contracts should be audited by a reputable third-party security firm to identify and address any potential vulnerabilities before they can be exploited.
Finally, it is important to follow best practices for smart contract development and deployment, such as using the latest version of the Solidity compiler, avoiding deprecated features, and thoroughly testing contracts before deploying them to the live network.
Contract Samples
Code with a vulnerability
pragma solidity ^0.4.21;
contract TokenSaleChallenge {
mapping(address => uint256) public balanceOf;
uint256 constant PRICE_PER_TOKEN = 1 ether;
function TokenSaleChallenge(address _player) public payable {
require(msg.value == 1 ether);
}
function isComplete() public view returns (bool) {
return address(this).balance < 1 ether;
}
function buy(uint256 numTokens) public payable {
require(msg.value == numTokens * PRICE_PER_TOKEN);
balanceOf[msg.sender] += numTokens;
}
function sell(uint256 numTokens) public {
require(balanceOf[msg.sender] >= numTokens);
balanceOf[msg.sender] -= numTokens;
msg.sender.transfer(numTokens * PRICE_PER_TOKEN);
}
}
Tools for scaning SWC-105
1. MythX: MythX is a cloud-based security analysis platform that offers a range of vulnerability detection tools, including SWC-105, as well as other SWC vulnerabilities, in Solidity smart contracts.
2. Solhint: Solhint is a linter for Solidity that helps developers identify and fix common issues, including deprecated functions or features, in Solidity smart contracts.
3. Slither: Slither is a static analysis framework for Solidity that can identify a wide range of vulnerabilities, including deprecated functions or features, in smart contracts.
4. Securify: Securify is a security scanner for Ethereum smart contracts that can detect various vulnerabilities, including deprecated functions or features, through static analysis.
5. Oyente: Oyente is a security analyzer for Ethereum smart contracts that can detect deprecated functions or features, as well as other vulnerabilities, through static analysis.
Общее перечисление слабых мест (CWE)
Mitigation for SWC-105
1. Use safe math libraries: To avoid integer overflow and underflow vulnerabilities, developers should use safe math libraries that provide secure arithmetic operations.
2. Restrict user input: Developers can validate user input and enforce constraints to prevent users from providing large values that could lead to overflow and underflow.
3. Use smaller data types: By using smaller data types, developers can reduce the likelihood of overflow and underflow vulnerabilities.
4. Use require statements: Developers can use require statements to ensure that values passed into functions are within a certain range or meet specific criteria.
5. Avoid complex mathematical operations: Developers should avoid complex mathematical operations that are prone to overflow and underflow vulnerabilities.
6. Use tests and audits: Comprehensive testing and auditing can help identify vulnerabilities and ensure that code is secure.
Заключение
SWC-105 highlights the vulnerability of the smart contract to an attack that is initiated through an unexpected function call. This can occur if the smart contract does not restrict access to sensitive functions and data to authorized parties. To avoid such vulnerabilities, developers must ensure that sensitive functions and data are only accessible to authorized parties. Developers should implement access control mechanisms, such as role-based access control or whitelisting, to restrict access to sensitive functions and data. Additionally, developers should be careful not to expose sensitive functions and data in their interfaces, and limit the exposure of the smart contract’s code to prevent attackers from discovering hidden vulnerabilities. Automated tools such as Mythril and Securify can be used to detect such vulnerabilities in smart contracts during the development phase, which can help in mitigating the risks associated with SWC-105.
Другие Услуги
Insomnia Security Scanner
AI-powered web application security scanner by CQR. Automated vulnerability discovery, exploit verification, and detailed reporting for modern applications.
Узнать большеЗащита Инфраструктуры CRYEYE
Аудит безопасности с помощью CryEye обеспечивает информационную безопасность предприятия, защищая всю инфраструктуру.
Узнать большеТестирование на проникновение
Найдите уязвимости во всей инфраструктуре вашего бизнеса раньше, чем это сделают хакеры! В рамках консалтинга по тестированию на проникновение мы подберем методы пентестов.
Узнать большеСоциальная инженерия
Simulate real-world phishing, vishing, and pretexting attacks to measure and improve your team's security awareness and response capabilities.
Узнать большеНагрузочное Тестирование
All kinds of load and performance testing of your system from the CQR online security company.
Узнать большеAI-Powered Vulnerability Assessment
Leverage artificial intelligence to discover, prioritize, and remediate vulnerabilities across your digital assets faster and more accurately than traditional scanners.
Узнать большеCloud Security Audit (AWS / GCP / Azure)
Comprehensive security review of your cloud environments — IAM policies, network controls, data exposure, and misconfigurations across all major cloud platforms.
Узнать большеDevSecOps Integration
Embed security into every stage of your CI/CD pipeline. Automated SAST, DAST, SCA, and secret scanning so vulnerabilities are caught before they reach production.
Узнать большеAPI Security Testing
In-depth testing of REST, GraphQL, and SOAP APIs for authentication flaws, authorization bypasses, injection vulnerabilities, and data leakage risks.
Узнать большеMobile Application Penetration Testing
Manual and automated security testing for iOS and Android applications — reverse engineering, runtime analysis, traffic interception, and backend API assessment.
Узнать большеIoT Security Assessment
Evaluate firmware, communication protocols, cloud backends, and physical interfaces of IoT devices to identify vulnerabilities before attackers do.
Узнать большеBlockchain & Smart Contract Audit
Formal verification and manual code review of smart contracts on Ethereum, Solana, and other chains. Detect reentrancy, overflow, and logic flaws before deployment.
Узнать большеRed Team Operations
Advanced adversary simulation using real attacker TTPs (MITRE ATT&CK) to test your detection, response, and overall security posture under realistic conditions.
Узнать большеThreat Intelligence & Monitoring
Continuous monitoring of threat feeds, dark web, and attacker infrastructure to provide actionable intelligence specific to your organization and industry.
Узнать большеZero Trust Architecture Review
Assess and design your Zero Trust security model — identity verification, micro-segmentation, least-privilege access, and continuous validation controls.
Узнать большеCompliance Consulting (PCI DSS / SOC 2 / GDPR)
Expert guidance to achieve and maintain compliance with major security frameworks. Gap analysis, remediation roadmaps, and audit-readiness support.
Узнать большеDark Web Monitoring
Continuous surveillance of dark web forums, marketplaces, and breach databases for leaked credentials, sensitive data, or mentions of your organization.
Узнать большеPhishing Simulation & Awareness Training
Controlled phishing campaigns combined with interactive security awareness training to build a human firewall across your entire organization.
Узнать большеSupply Chain Security Audit
Assess third-party vendor risks, open-source dependencies, and software supply chain integrity to prevent attacks like SolarWinds and Log4Shell.
Узнать большеContainer & Kubernetes Security
Security review of Docker images, Kubernetes clusters, RBAC policies, network policies, and runtime configurations to harden your container infrastructure.
Узнать большеWeb Application Firewall (WAF) Deployment
Professional WAF setup, rule tuning, and ongoing management to block SQL injection, XSS, CSRF, and other OWASP Top 10 threats in real time.
Узнать большеBug Bounty Program Management
Full lifecycle management of your bug bounty program — scope definition, researcher coordination, triage, validation, and remediation tracking.
Узнать большеOSINT Investigation Services
Open-source intelligence gathering on individuals, organizations, and infrastructure. Ideal for pre-engagement recon, fraud investigation, and competitive analysis.
Узнать большеDigital Forensics & Incident Response
Rapid response to security breaches — evidence collection, malware analysis, attacker timeline reconstruction, and actionable remediation recommendations.
Узнать больше