मुख्य सामग्री पर जाएँ
Skillpedia
सिक्योरिटी6.5k · #14005

access-control

यह क्या करती है

यह प्लेबुक स्मार्ट कॉन्ट्रैक्ट में समीक्षा का मार्गदर्शन करती है कि कौन ज़रूरी सेटिंग बदल सकता है या फ़ंड स्थानांतरित कर सकता है। यह उन ऑडिटरों और डेवलपर्स के लिए है जो अनुमति जाँच की पुष्टि चाहते हैं।

कब इस्तेमाल करें

  • ✓जब Solidity कॉन्ट्रैक्ट में ऐसे फ़ंक्शन हों जो मालिकाना हक, सेटिंग या फ़ंड बदलते हैं।
  • ✓जब आप जाँचना चाहते हैं कि role या owner की जाँच सही है या नहीं।
  • ✓जब टीम ऐसे public फ़ंक्शन खोजना चाहती है जिन्हें प्रतिबंधित होना चाहिए था।

Skill का लिंक

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/access-control/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/contracts/access-control/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“क्या आप जाँच सकते हैं कि हमारे कॉन्ट्रैक्ट के किसी एडमिन फ़ंक्शन में सही owner जाँच गायब है?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट हर उस फ़ंक्शन को खोजता है जो स्टेट बदलता है, देखता है कि कौन-सा अनुमति modifier लागू है, और गायब या गलत जाँच वाले फ़ंक्शन चिह्नित करता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Access Control Playbook

Access control bugs are the most boring class — and the most common in production audits. They're cheap to find with grep + LSP. They drain millions when missed (LeetSwap, Audius, Saddle, Akropolis).

Audit steps

1. Find every state-changing function

# Functions that are NOT view/pure and NOT internal/private
grep -rE 'function [a-zA-Z_]+\(.*\)(public|external)' src/ | grep -v 'view\|pure'

# Or via slither
slither . --print function-summary

2. For each external/public state-changer, ask

  • Does it modify storage that affects user funds, ownership, or configuration?
  • Is there a modifier (onlyOwner, onlyRole, onlyDAO, custom auth)?
  • If yes, what's the modifier checking?
  • If no, should there be one?

3. Audit each modifier

Common modifier patterns + bugs:

Pattern Bug
require(msg.sender == owner) owner settable by anyone? setOwner unprotected?
require(msg.sender == tx.origin) Wrong — tx.origin breaks meta-transactions, AND it's phishable
_msgSender() in OZ ERC2771Context Forwarder trusted but anyone can forward — does the contract validate the forwarder?
onlyRole(MINTER) Who can grant MINTER? Is the admin a multisig or single key?
require(initialized == false) Initializer can be called twice if initialized writeable elsewhere
require(block.timestamp > deployTime + 24 hours) Time-based is often a fake delay — check if deployTime is settable
require(approvedSigners[msg.sender]) Approval list managed by single key?

4. Specific anti-patterns to grep

# Functions accidentally external (default in Solidity <0.5)
grep -rn 'function [a-zA-Z_]*[^ ]* *{' src/ | grep -v 'internal\|private\|public\|external'

# msg.sender == tx.origin (phishable)
grep -rn 'tx.origin' src/

# Reentrancy in access-control checks
grep -rn 'onlyOwner.*nonReentrant' src/   # both? often wrong order

# `delegatecall` without auth gate
grep -rn 'delegatecall' src/

# `selfdestruct` available
grep -rn 'selfdestruct\|suicide(' src/

5. Initializer bugs

// VULNERABLE
function initialize(address _owner) external {
    owner = _owner;
    // missing: require(!initialized); initialized = true;
}

// VULNERABLE (proxy implementation)
contract Impl {
    constructor() { ... }  // NEVER RUNS in proxy context
    // initialize() should set proxy state but doesn't gate
}

// SAFE
function initialize(address _owner) external initializer {
    // OZ's initializer modifier enforces single-call
    __Ownable_init(_owner);
}

For UUPS/Transparent proxies: check _authorizeUpgrade is overridden and gated. Default OZ override is empty (revert).

6. Function-selector collisions (proxies)

Transparent proxy admin function selectors collide w/ impl function selectors → admin functions become uncallable, OR impl functions are shadowed by admin. Check w/ slither:

slither-check-erc src/Impl.sol --erc ERC1967

7. Role grant/revoke

For AccessControl:

  • DEFAULT_ADMIN_ROLE is the admin of all roles by default
  • Anyone with DEFAULT_ADMIN_ROLE can grant any role to anyone
  • If init code grants DEFAULT_ADMIN_ROLE to deployer w/ no transfer to multisig → key person risk

Check role hierarchy:

grep -rn '_setRoleAdmin\|_setupRole\|grantRole' src/

PoC template (Foundry)

function test_unauth_call() public {
    address attacker = address(0xBEEF);
    vm.prank(attacker);

    // Call the function that should require auth
    target.dangerousFunction(arg1, arg2);

    // Assert state change happened
    assertEq(target.criticalParam(), expectedManipulatedValue);
    // No revert = vulnerable
}

function test_role_takeover() public {
    address attacker = address(0xBEEF);
    vm.startPrank(attacker);

    // If grantRole is callable by anyone
    target.grantRole(target.MINTER_ROLE(), attacker);
    assertTrue(target.hasRole(target.MINTER_ROLE(), attacker));

    // Now exploit MINTER_ROLE
    target.mint(attacker, 1_000_000 ether);
}

function test_init_re_entry() public {
    // Call initialize twice
    target.initialize(address(this));
    vm.expectRevert("Initializable: contract is already initialized");
    target.initialize(attacker);
}

function test_upgrade_no_auth() public {
    address attacker = address(0xBEEF);
    address malicious = address(new MaliciousImpl());

    vm.prank(attacker);
    target.upgradeTo(malicious);

    // Now any call goes to
अक्सर पूछे जाने वाले सवाल

यह बग श्रेणी इतनी आम क्यों है?

प्लेबुक इसे प्रोडक्शन ऑडिट की सबसे आम श्रेणी बताती है, और सरल खोज से इसे ढूँढना सस्ता है।

एक आम गलत पैटर्न क्या है?

अनुमति के लिए tx.origin इस्तेमाल करना, जिसे प्लेबुक गलत बताती है और जो फ़िशिंग से दुरुपयोग हो सकता है।

एजेंट role के बारे में क्या जाँचता है?

कौन role दे सकता है, और क्या एडमिन multisig है या एक ही key।

जानकारी

लेखक का मूल विवरण

Missing modifiers, wrong msg.sender checks, default-public functions, missing onlyOwner / onlyRole / onlyDAO authorization.

repo: BitterSecurity/Decepticon

लोकप्रियता

GitHub स्टार
6.5k
रैंकिंग में स्थान
#14005
लाइसेंस
Apache-2.0
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

detector-overview

6.5k

यह आपके एजेंट को स्कैनर से चिह्नित कोड पढ़ने और तय करने में मदद करती है कि कौन सी जगहें असली सुरक्षा बग हैं और कौन सी गलत चेतावनी।

कोडिंगसिक्योरिटी

exploiter-overview

6.5k

यह आपके एजेंट को कई पक्की सुरक्षा कमज़ोरियों को एक परीक्षण श्रृंखला में जोड़ने और जाँचने में मदद करती है कि वह श्रृंखला कितनी दूर तक पहुँच सकती है।

कोडिंगसिक्योरिटी

llm-redteam-overview

6.5k

यह आपके एजेंट को परीक्षण के लिए सही AI रेड-टीम गाइड खोजने में मदद करती है, प्रॉम्प्ट इंजेक्शन से लेकर मॉडल के दुरुपयोग तक 15 रणनीति समूहों में।

कोडिंगसिक्योरिटी

aatmf-t01-prompt-injection

6.5k

समझाती है कि प्रॉम्प्ट इंजेक्शन क्या है, जिसमें छिपे निर्देश AI सिस्टम के नियम बदलने की कोशिश करते हैं, ताकि सुरक्षा परीक्षक उसकी जाँच कर सकें।

कोडिंगसिक्योरिटी

मिलती-जुलती skills