racket / racket/racket

Sandbox forbids access to transformer of macro in binding space

Open
#4,186 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

component: macro
Dominant language
Racket
Stars
5.2k
Forks
698
Avg merge
18h 34m
Merged PRs (30d)
5

Description

What version of Racket are you using?

8.4.0.8 [cs]

What program did you run?

sp-a.rkt:

#lang racket

(provide
 (for-space sp x)
 m)

(define-syntax (define-syntax/sp stx)
  (syntax-case stx ()
    [(_ var rhs)
     (with-syntax ([sp-var ((make-interned-syntax-introducer 'sp) #'var)])
       #'(define-syntax sp-var rhs))]))

(define-syntax/sp x 'x-info)

(define-syntax (m stx)
  (syntax-case stx ()
    [(_ id)
     #`'#,(syntax-local-value ((make-interned-syntax-introducer 'sp) #'id))]))

sp-b.rkt

#lang racket

(require racket/sandbox)

(define evaluator
  (make-evaluator 'racket/base
                  '(require "sp-a.rkt")
                  #:allow-for-require (list "sp-a.rkt")))

(evaluator '(m x))

What should have happened?

The expression (evaluator '(m x)) should evaluate to 'x-info.

If you got an error message, please include it here.

eval:1:0: ?: access disallowed by code inspector to unexported transformer
  from module: "/Users/michaelballantyne/Desktop/sp-a.rkt" in: x

The analogous code that does not use binding spaces works:

a.rkt:

#lang racket

(provide
 x
 m)

(define-syntax x 'x-info)

(define-syntax (m stx)
  (syntax-case stx ()
    [(_ id)
     #`'#,(syntax-local-value #'id)]))

b.rkt:

#lang racket

(require racket/sandbox)

(define evaluator
  (make-evaluator 'racket/base
                  '(require "a.rkt")
                  #:allow-for-require (list "a.rkt")))

(evaluator '(m x))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproduction in sp-a.rkt and sp-b.rkt with Racket 8.4.0.8 [cs], then inspect the sandbox and code-inspector paths responsible for the unexported transformer error. Done means the evaluator call returns 'x-info while the analogous non-binding-space case continues to work.

Written by the indexing model from the issue text.

Assessment

Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.