sup 0.14.1 → 0.14.1.1
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.
- data/History.txt +10 -0
- data/ReleaseNotes +26 -0
- data/lib/sup/message_chunks.rb +53 -13
- data/lib/sup/version.rb +1 -1
- metadata +4 -3
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 0.14.1.1 / 2013-10-29
|
2
|
+
|
3
|
+
* SBU1: security release
|
4
|
+
* Tempfiles for attachments are persistent through the sup process to
|
5
|
+
ensure that spawned processes have access to them.
|
6
|
+
|
7
|
+
== 0.13.2.1 / 2013-10-29
|
8
|
+
|
9
|
+
* SBU1: security release
|
10
|
+
|
1
11
|
== 0.14.1 / 2013-08-31
|
2
12
|
|
3
13
|
* Various bugfixes.
|
data/ReleaseNotes
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
Release 0.14.1.1:
|
2
|
+
|
3
|
+
See 0.13.2.1.
|
4
|
+
|
5
|
+
Release 0.13.2.1:
|
6
|
+
|
7
|
+
Security advisory (#SBU1) for Sup
|
8
|
+
|
9
|
+
We have been notified of an potential exploit in the somewhat careless
|
10
|
+
way Sup treats attachment metadata in received e-mails. The issues
|
11
|
+
should now be fixed and I have released Sup 0.13.2.1 and 0.14.1.1 which
|
12
|
+
incorporates these fixes. Please upgrade immediately and also ensure
|
13
|
+
that your mime-decode or mime-view hooks are secure [0], [1].
|
14
|
+
|
15
|
+
This is specifically related to using quotes (',") around filename or
|
16
|
+
content_type which is already escaped using Ruby Shellwords.escape -
|
17
|
+
this means that the string (content_type, filename) is intended to be
|
18
|
+
used _without_ any further quotes. Please make sure that if you use
|
19
|
+
.mailcap (non OSX systems), you do not quote the string.
|
20
|
+
|
21
|
+
Credit goes to: joernchen of Phenoelit (http://phenoelit.de) who
|
22
|
+
discovered and suggested fixes for these issues.
|
23
|
+
|
24
|
+
[0] https://github.com/sup-heliotrope/sup/wiki/Viewing-Attachments
|
25
|
+
[1] https://github.com/sup-heliotrope/sup/wiki/Secure-usage-of-Sup
|
26
|
+
|
1
27
|
Release 0.14.1:
|
2
28
|
|
3
29
|
Service release to 0.14.0 plus a predefined 'All mail' search.
|
data/lib/sup/message_chunks.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'tempfile'
|
2
2
|
require 'rbconfig'
|
3
|
+
require 'shellwords'
|
3
4
|
|
4
5
|
## Here we define all the "chunks" that a message is parsed
|
5
6
|
## into. Chunks are used by ThreadViewMode to render a message. Chunks
|
@@ -59,6 +60,8 @@ end
|
|
59
60
|
module Redwood
|
60
61
|
module Chunk
|
61
62
|
class Attachment
|
63
|
+
## please see note in write_to_disk on important usage
|
64
|
+
## of quotes to avoid remote command injection.
|
62
65
|
HookManager.register "mime-decode", <<EOS
|
63
66
|
Decodes a MIME attachment into text form. The text will be displayed
|
64
67
|
directly in Sup. For attachments that you wish to use a separate program
|
@@ -75,6 +78,9 @@ Return value:
|
|
75
78
|
The decoded text of the attachment, or nil if not decoded.
|
76
79
|
EOS
|
77
80
|
|
81
|
+
|
82
|
+
## please see note in write_to_disk on important usage
|
83
|
+
## of quotes to avoid remote command injection.
|
78
84
|
HookManager.register "mime-view", <<EOS
|
79
85
|
Views a non-text MIME attachment. This hook allows you to run
|
80
86
|
third-party programs for attachments that require such a thing (e.g.
|
@@ -100,8 +106,18 @@ EOS
|
|
100
106
|
attr_reader :content_type, :filename, :lines, :raw_content
|
101
107
|
bool_reader :quotable
|
102
108
|
|
109
|
+
## store tempfile objects as class variables so that they
|
110
|
+
## are not removed when the viewing process returns. they
|
111
|
+
## should be garbage collected when the class variable is removed.
|
112
|
+
@@view_tempfiles = []
|
113
|
+
|
103
114
|
def initialize content_type, filename, encoded_content, sibling_types
|
104
115
|
@content_type = content_type.downcase
|
116
|
+
if Shellwords.escape(@content_type) != @content_type
|
117
|
+
warn "content_type #{@content_type} is not safe, changed to application/octet-stream"
|
118
|
+
@content_type = 'application/octet-stream'
|
119
|
+
end
|
120
|
+
|
105
121
|
@filename = filename
|
106
122
|
@quotable = false # changed to true if we can parse it through the
|
107
123
|
# mime-decode hook, or if it's plain text
|
@@ -116,7 +132,9 @@ EOS
|
|
116
132
|
when /^text\/plain\b/
|
117
133
|
@raw_content
|
118
134
|
else
|
119
|
-
|
135
|
+
## please see note in write_to_disk on important usage
|
136
|
+
## of quotes to avoid remote command injection.
|
137
|
+
HookManager.run "mime-decode", :content_type => @content_type,
|
120
138
|
:filename => lambda { write_to_disk },
|
121
139
|
:charset => encoded_content.charset,
|
122
140
|
:sibling_types => sibling_types
|
@@ -125,7 +143,13 @@ EOS
|
|
125
143
|
@lines = nil
|
126
144
|
if text
|
127
145
|
text = text.transcode(encoded_content.charset || $encoding, text.encoding)
|
128
|
-
|
146
|
+
begin
|
147
|
+
@lines = text.gsub("\r\n", "\n").gsub(/\t/, " ").gsub(/\r/, "").split("\n")
|
148
|
+
rescue Encoding::CompatibilityError
|
149
|
+
@lines = text.fix_encoding!.gsub("\r\n", "\n").gsub(/\t/, " ").gsub(/\r/, "").split("\n")
|
150
|
+
debug "error while decoding message text, falling back to default encoding, expect errors in encoding: #{text.fix_encoding!}"
|
151
|
+
end
|
152
|
+
|
129
153
|
@quotable = true
|
130
154
|
end
|
131
155
|
end
|
@@ -147,11 +171,13 @@ EOS
|
|
147
171
|
def initial_state; :open end
|
148
172
|
def viewable?; @lines.nil? end
|
149
173
|
def view_default! path
|
174
|
+
## please see note in write_to_disk on important usage
|
175
|
+
## of quotes to avoid remote command injection.
|
150
176
|
case RbConfig::CONFIG['arch']
|
151
177
|
when /darwin/
|
152
|
-
cmd = "open
|
178
|
+
cmd = "open #{path}"
|
153
179
|
else
|
154
|
-
cmd = "/usr/bin/run-mailcap --action=view
|
180
|
+
cmd = "/usr/bin/run-mailcap --action=view #{@content_type}:#{path}"
|
155
181
|
end
|
156
182
|
debug "running: #{cmd.inspect}"
|
157
183
|
BufferManager.shell_out(cmd)
|
@@ -159,17 +185,31 @@ EOS
|
|
159
185
|
end
|
160
186
|
|
161
187
|
def view!
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
188
|
+
## please see note in write_to_disk on important usage
|
189
|
+
## of quotes to avoid remote command injection.
|
190
|
+
write_to_disk do |file|
|
191
|
+
|
192
|
+
@@view_tempfiles.push file # make sure the tempfile is not garbage collected before sup stops
|
193
|
+
|
194
|
+
ret = HookManager.run "mime-view", :content_type => @content_type,
|
195
|
+
:filename => file.path
|
196
|
+
ret || view_default!(file.path)
|
197
|
+
end
|
166
198
|
end
|
167
199
|
|
200
|
+
## note that the path returned from write_to_disk is
|
201
|
+
## Shellwords.escaped and is intended to be used without single
|
202
|
+
## or double quotes. the use of either opens sup up for remote
|
203
|
+
## code injection through the file name.
|
168
204
|
def write_to_disk
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
205
|
+
begin
|
206
|
+
file = Tempfile.new(["sup", Shellwords.escape(@filename.gsub("/", "_")) || "sup-attachment"])
|
207
|
+
file.print @raw_content
|
208
|
+
yield file if block_given?
|
209
|
+
return file.path
|
210
|
+
ensure
|
211
|
+
file.close
|
212
|
+
end
|
173
213
|
end
|
174
214
|
|
175
215
|
## used when viewing the attachment as text
|
@@ -229,7 +269,7 @@ EOS
|
|
229
269
|
class EnclosedMessage
|
230
270
|
attr_reader :lines
|
231
271
|
def initialize from, to, cc, date, subj
|
232
|
-
@from = from ? "unknown sender" : from.
|
272
|
+
@from = from ? "unknown sender" : from.full_address
|
233
273
|
@to = to ? "" : to.map { |p| p.full_address }.join(", ")
|
234
274
|
@cc = cc ? "" : cc.map { |p| p.full_address }.join(", ")
|
235
275
|
if date
|
data/lib/sup/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.1
|
4
|
+
version: 0.14.1.1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 14
|
9
9
|
- 1
|
10
|
-
|
10
|
+
- 1
|
11
|
+
hash: -295629968094096073
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- William Morgan
|
@@ -17,7 +18,7 @@ authors:
|
|
17
18
|
autorequire:
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
|
-
date: 2013-
|
21
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: xapian-ruby
|