envameleon 0.2.0-universal-mingw → 0.4.0-universal-mingw

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +66 -30
  3. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76320666462ab75a0de8ccec9a4f51f2a0bf5d25342fa798a647c6e53f7c2b66
4
- data.tar.gz: b31c3bc6f236daf24c859f43450a794cd6fbcb7d2d42ce44e9eb6f683e0512b5
3
+ metadata.gz: 8c358b45f11e91cb4437e2152c1be03e1f28d2d3fce7d62a927e552b3c93ac5d
4
+ data.tar.gz: 0dc6069f5720232f4745b9fa86e896e138c3b0bf7c99752c4753df317551bdbd
5
5
  SHA512:
6
- metadata.gz: 06f34cc1a6b2d3143e56b474d3e5aab7e368259f211dc9db459cf2d60bcdda1d4022ddef2e1df21b87f76bfe0e7b0cb186fa90a264de264a6fbcdeb9944563d1
7
- data.tar.gz: ef6f91088ba51fe266904665a77cef33f2b2d54de2773867017a509399a719638f412d3969ae2495bad1e5210a20938a55eb1b45b69488f450fd5c49ee0b9f1d
6
+ metadata.gz: 23f1a49ab5dbf7c30819c6d3f74d97b180aa3425e2b99a7cc6851cd0c5be11a1b41878c88604df7536e25155b33e1314a2c854629296f5e13f5e701a6f34137e
7
+ data.tar.gz: '084f577c069aa6d3952cfcc4b4bb28d93ec9adf3de129781a11e770282978ca77d08800423cfdc79f6c037c5692404fad659713367d59aa0412fd358c6393ce3'
data/README.md CHANGED
@@ -105,7 +105,7 @@ Every GitHub release includes the gems and `SHA256SUMS`. Release gems also have
105
105
  GitHub build-provenance attestations, which can be checked with:
106
106
 
107
107
  ```console
108
- gh attestation verify envameleon-0.2.0-x86_64-linux-gnu.gem --repo kpumuk/envameleon
108
+ gh attestation verify envameleon-0.4.0-x86_64-linux-gnu.gem --repo kpumuk/envameleon
109
109
  ```
110
110
 
111
111
  [Back to top](#readme-top).
@@ -119,7 +119,7 @@ ENV.mask_proc_data
119
119
  # SECRET=example becomes SECRET=e*****e in /proc/self/environ
120
120
 
121
121
  ENV.scrub_proc_data
122
- # /proc/self/environ now holds only NUL bytes
122
+ # /proc/self/environ now holds NUL bytes except for any LD_LIBRARY_PATH entry
123
123
 
124
124
  ENV.drop_proc_data
125
125
  # /proc/self/environ is now zero bytes long
@@ -127,8 +127,8 @@ ENV.drop_proc_data
127
127
 
128
128
  | Method | Result in `/proc/self/environ` | File length | Permissions |
129
129
  | --- | --- | --- | --- |
130
- | `ENV.mask_proc_data` | Names plus the first and last value byte | Unchanged | None |
131
- | `ENV.scrub_proc_data` | NUL bytes | Unchanged | None |
130
+ | `ENV.mask_proc_data` | Names plus the first and last value byte; `LD_LIBRARY_PATH` untouched | Unchanged | None |
131
+ | `ENV.scrub_proc_data` | NUL bytes except for `LD_LIBRARY_PATH` | Unchanged | None |
132
132
  | `ENV.drop_proc_data` | Empty | Zero | `CAP_SYS_RESOURCE` |
133
133
 
134
134
  Choose the least power you need.
@@ -137,8 +137,14 @@ Choose the least power you need.
137
137
  > `ENV.drop_proc_data` requires `CAP_SYS_RESOURCE` on Linux. Without it, the
138
138
  > method raises `Errno::EPERM`.
139
139
 
140
- Masking works on raw bytes, not characters. It replaces all value bytes except
141
- the first and last with `*`. Values shorter than three bytes stay unchanged.
140
+ Masking works on raw bytes, not characters. For entries it masks, it replaces
141
+ all value bytes except the first and last with `*`. Values shorter than three
142
+ bytes stay unchanged.
143
+
144
+ Masking and scrubbing leave the original `LD_LIBRARY_PATH` entry visible on all
145
+ Linux systems because the musl dynamic linker still uses its original bytes to
146
+ find libraries. Changing or deleting the variable in Ruby's `ENV` does not
147
+ change the original entry. Dropping hides it without rewriting the bytes.
142
148
 
143
149
  [Back to top](#readme-top).
144
150
 
@@ -158,7 +164,8 @@ start. This makes `/proc/self/environ` truly zero-length. Linux requires the
158
164
 
159
165
  ## Process Inheritance
160
166
 
161
- Call a method before `fork` and each child inherits the changed proc view. Ruby
167
+ Call a method before `fork` and each child inherits the changed proc view.
168
+ `fork` copies the changed bytes and does not rebuild them from Ruby `ENV`. Ruby
162
169
  `ENV` remains available in the parent and children. The test suite checks this
163
170
  with a second fork for all three methods.
164
171
 
@@ -167,36 +174,48 @@ proc environment. That program must load ENVameleon and call a method itself.
167
174
 
168
175
  ### Forking servers
169
176
 
170
- You may call a method in the parent before it forks. You may also call it from a
171
- worker boot hook. These examples use scrubbing, which needs no extra right.
177
+ Call the method in the parent before it forks so workers inherit the changed
178
+ view. Scrubbing leaves `LD_LIBRARY_PATH` visible in both the parent and workers.
179
+
180
+ Do not rely on a worker boot hook alone. It changes only the worker. The parent
181
+ runs as the same user, so anyone who can read the worker's files can also read
182
+ `/proc/<parent pid>/environ`.
183
+
184
+ These examples use scrubbing, which needs no extra right. In the Unicorn, Puma,
185
+ and Karafka examples, a failed call stops the server before it starts work.
172
186
 
173
187
  #### Unicorn
174
188
 
189
+ Call the method at the top of the Unicorn config file. The master evaluates it
190
+ before it forks workers.
191
+
175
192
  ```ruby
193
+ # config/unicorn.rb
176
194
  require "envameleon"
177
195
 
178
- after_fork do |_server, _worker|
179
- ENV.scrub_proc_data
180
- end
196
+ ENV.scrub_proc_data
181
197
  ```
182
198
 
183
199
  #### Puma
184
200
 
185
- Use `before_worker_boot` for cluster workers. In single mode, call the method
186
- during app boot.
201
+ Call the method at the top of `config/puma.rb`. This works in single and
202
+ cluster mode.
187
203
 
188
204
  ```ruby
205
+ # config/puma.rb
189
206
  require "envameleon"
190
207
 
191
- before_worker_boot do
192
- ENV.scrub_proc_data
193
- end
208
+ ENV.scrub_proc_data
194
209
  ```
195
210
 
211
+ Puma logs and ignores errors raised in `before_worker_boot`. A failed call
212
+ there leaves the worker running with its environment visible.
213
+
196
214
  #### Sidekiq
197
215
 
198
216
  Standard Sidekiq uses threads. Its startup hook runs before work begins. Sidekiq
199
- Enterprise Swarm runs the hook in each child.
217
+ Enterprise Swarm runs the hook in each child. The swarm parent is a separate
218
+ process and keeps its own view. See [Security Limits](#security-limits).
200
219
 
201
220
  ```ruby
202
221
  require "envameleon"
@@ -208,15 +227,15 @@ end
208
227
 
209
228
  #### Karafka
210
229
 
211
- The `app.running` event runs in the server process. In Swarm mode, it runs in
212
- each forked node.
230
+ Call the method at the top of `karafka.rb`. Both `karafka server` and the Swarm
231
+ supervisor load this file before they start work. Swarm nodes inherit the
232
+ changed view. The `app.running` event never runs in the Swarm supervisor.
213
233
 
214
234
  ```ruby
235
+ # karafka.rb
215
236
  require "envameleon"
216
237
 
217
- Karafka::App.monitor.subscribe("app.running") do
218
- ENV.scrub_proc_data
219
- end
238
+ ENV.scrub_proc_data
220
239
  ```
221
240
 
222
241
  If a child calls `ENV.drop_proc_data`, it must still have the needed Linux right.
@@ -235,9 +254,22 @@ ENVameleon changes only what `/proc/self/environ` shows. It does not erase every
235
254
  copy of a secret. It gives no protection from memory disclosure, debuggers, or
236
255
  core dumps.
237
256
 
257
+ ENVameleon changes only the process that calls it and the children it forks
258
+ later. Any other process started with the secret still shows it in
259
+ `/proc/<pid>/environ`. That includes the parent, PID 1 in a container, wrapper
260
+ shells, and process managers. A process running as the same user can usually
261
+ read those files. Start the app with `exec` so no wrapper shell stays behind.
262
+
238
263
  Dropping leaves the old bytes in memory. Masking keeps variable names and the
239
- outer bytes of each value. Short values remain fully visible. Scrubbing
240
- overwrites the old proc range, but a secret may still exist elsewhere.
264
+ outer bytes of masked values. Short values remain fully visible. Masking and
265
+ scrubbing both leave `LD_LIBRARY_PATH` visible in `/proc/self/environ` if it was
266
+ present at startup and has not already been overwritten.
267
+
268
+ Code that saved a pointer into the original environment before Ruby started,
269
+ such as the dynamic linker or a preloaded library, sees any bytes that masking
270
+ or scrubbing rewrites, even though Ruby's `ENV` stays unchanged. Neither method
271
+ can restore an entry that a long process title or other code has already
272
+ overwritten.
241
273
 
242
274
  [Back to top](#readme-top).
243
275
 
@@ -250,6 +282,7 @@ elsewhere:
250
282
  ```console
251
283
  bundle install
252
284
  bundle exec rake test
285
+ bundle exec rake standard
253
286
  ```
254
287
 
255
288
  On Linux, the drop test runs when `CAP_SYS_RESOURCE` is available. Otherwise,
@@ -261,15 +294,18 @@ Build the macOS and Windows no-op gems and the Linux source fallback with:
261
294
  bundle exec rake gem
262
295
  ```
263
296
 
264
- Native builds run inside the versioned image selected by the
265
- checksum-locked `rake-compiler-dock` gem. The image installs the exact Bundler
266
- version recorded in `Gemfile.lock`; Bundler then validates its own locked
267
- checksum and installs every other dependency from the prepared local cache:
297
+ Native builds run in a container image pinned by digest for each platform.
298
+ The build downloads the Bundler version recorded in `Gemfile.lock` and verifies
299
+ its SHA-256 checksum before installing or running it. Bundler then installs the
300
+ remaining dependencies from the prepared local cache and checks their locked
301
+ checksums. If a `rake-compiler-dock` update changes its image version, update the
302
+ version and digests in [`.github/scripts/native_platforms.rb`](.github/scripts/native_platforms.rb)
303
+ in the same change; native build tasks reject an image version mismatch.
268
304
 
269
305
  ```console
270
306
  bundle cache --all-platforms
271
307
  bundle exec rake gem:x86_64-linux-gnu
272
- ruby .github/scripts/verify_native_gem.rb pkg/envameleon-0.2.0-x86_64-linux-gnu.gem x86_64-linux-gnu
308
+ ruby .github/scripts/verify_native_gem.rb pkg/envameleon-0.4.0-x86_64-linux-gnu.gem x86_64-linux-gnu
273
309
  ```
274
310
 
275
311
  ## License
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envameleon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: universal-mingw
6
6
  authors:
7
7
  - Dmytro Shteflyuk
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '1.12'
54
+ - !ruby/object:Gem::Dependency
55
+ name: standard
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.56'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.56'
54
68
  - !ruby/object:Gem::Dependency
55
69
  name: test-unit
56
70
  requirement: !ruby/object:Gem::Requirement
@@ -89,14 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
103
  requirements:
90
104
  - - ">="
91
105
  - !ruby/object:Gem::Version
92
- version: '3.2'
106
+ version: 3.2.0
93
107
  required_rubygems_version: !ruby/object:Gem::Requirement
94
108
  requirements:
95
109
  - - ">="
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
98
112
  requirements: []
99
- rubygems_version: 4.0.16
113
+ rubygems_version: 4.0.20
100
114
  specification_version: 4
101
115
  summary: Leave no ENVidence.
102
116
  test_files: []