File tree Expand file tree Collapse file tree 4 files changed +76
-0
lines changed Expand file tree Collapse file tree 4 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ RUN apt-get update && apt-get install -y \
20
20
21
21
RUN useradd -m playground -d /playground
22
22
RUN usermod -p '!!' root # Disable all passwords for root
23
+
24
+ # Attach the security note
25
+ ADD --chown=playground attach_notice.sh security_notice.txt /playground/
26
+ RUN /playground/attach_notice.sh /playground/security_notice.txt /etc/passwd && \
27
+ /playground/attach_notice.sh /playground/security_notice.txt /etc/shadow && \
28
+ rm -f /playground/attach_notice.sh
29
+
23
30
USER playground
24
31
ENV USER=playground
25
32
ENV PATH=/playground/.cargo/bin:$PATH
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -eu
4
+
5
+ NOTICE_FILE=$1 # full path to the notice file
6
+ TARGET_FILE=$2 # full patch to the target file
7
+
8
+ POSITION=${3:- " top" } # possible values: top or bottom; default value: top
9
+
10
+ function attach_notice() {
11
+ echo " Attaching ${NOTICE_FILE} to ${TARGET_FILE} (position: ${POSITION} )"
12
+
13
+ if [[ " ${POSITION} " == " bottom" ]]; then
14
+ cat " ${NOTICE_FILE} " >> " ${TARGET_FILE} "
15
+ else
16
+ combined=$( mktemp)
17
+ cat " ${NOTICE_FILE} " " ${TARGET_FILE} " >> " ${combined} "
18
+ chmod --reference " ${TARGET_FILE} " " ${combined} "
19
+ mv " ${combined} " " ${TARGET_FILE} "
20
+ fi
21
+
22
+ echo " Done."
23
+ }
24
+
25
+ if [[ -f " ${NOTICE_FILE} " ]] && [[ -f " ${TARGET_FILE} " ]]; then
26
+ attach_notice
27
+ fi
Original file line number Diff line number Diff line change
1
+ # Hello, and thanks for looking into the Rust Playground's security!
2
+ #
3
+ # This build is running on an unprivileged, sandboxed Docker container with no
4
+ # network access, so while you can technically run arbitrary code on the
5
+ # Playground you shouldn't be able to do any damage with it.
6
+ #
7
+ # Nothing is perfect though: if you find a way to escape the sandbox, please
8
+ # disclose it following our security policy! You can find the policy at:
9
+ #
10
+ # https://www.rust-lang.org/policies/security
11
+ #
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+ require 'support/editor'
3
+ require 'support/playground_actions'
4
+
5
+ RSpec . feature "Security concerns" , type : :feature , js : true do
6
+ include PlaygroundActions
7
+
8
+ before do
9
+ visit '/'
10
+ editor . set ( code )
11
+ end
12
+
13
+ scenario "a notice is present for filesystem snoopers" do
14
+ within ( :header ) { click_on ( "Run" ) }
15
+ within ( :output , :stdout ) do
16
+ expect ( page ) . to have_content 'www.rust-lang.org/policies/security'
17
+ end
18
+ end
19
+
20
+ def editor
21
+ Editor . new ( page )
22
+ end
23
+
24
+ def code
25
+ <<~EOF
26
+ fn main() {
27
+ println!("{}", std::fs::read_to_string("/etc/passwd").unwrap());
28
+ }
29
+ EOF
30
+ end
31
+ end
You can’t perform that action at this time.
0 commit comments