Skip to content
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

Possible to cause a runtime error due to invalid entitlements that should be caught at checker time #2839

Closed
dsainati1 opened this issue Oct 4, 2023 · 0 comments
Assignees
Labels
Bug Something isn't working Feedback

Comments

@dsainati1
Copy link
Contributor

Current Behavior

entitlement X
entitlement Y
entitlement mapping M {
    X -> Insert
    Y -> Remove
}
struct S {
    access(M) var member: auth(M) &[Int]?
    init() {
        self.member = nil;
    }
    access(all) fun grantRemovePrivileges(param: auth(Insert) &[Int]): Void{
        var selfRef = &self as auth(X) &S;
        selfRef.member = param;
    }
}
fun main(): Void {
    var arr: [Int] = [123];
    var arrRef = &arr as auth(Insert) &[Int];
    let s = S()
    s.grantRemovePrivileges(param: arrRef);
    s.member?.removeLast() // Caught by checkMemberAccess type check
}

Expected Behavior

Should fail in the type checker

Steps To Reproduce

Create this as a test on stable cadence branch

Environment

- Cadence version: Stable Cadence
- Network:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Feedback
Projects
None yet
Development

No branches or pull requests

2 participants