Skip to content

Commit c7620bd

Browse files
jrngitster
authored andcommitted
upload-pack: disable object filtering when disabled by config
When upload-pack gained partial clone support (v2.17.0-rc0~132^2~12, 2017-12-08), it was guarded by the uploadpack.allowFilter config item to allow server operators to control when they start supporting it. That config item didn't go far enough, though: it controls whether the 'filter' capability is advertised, but if a (custom) client ignores the capability advertisement and passes a filter specification anyway, the server would handle that despite allowFilter being false. This is particularly significant if a security bug is discovered in this new experimental partial clone code. Installations without uploadpack.allowFilter ought not to be affected since they don't intend to support partial clone, but they would be swept up into being vulnerable. Simplify and limit the attack surface by making uploadpack.allowFilter disable the feature, not just the advertisement of it. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9f242a1 commit c7620bd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Documentation/config.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3270,7 +3270,7 @@ uploadpack.packObjectsHook::
32703270
stdout.
32713271

32723272
uploadpack.allowFilter::
3273-
If this option is set, `upload-pack` will advertise partial
3273+
If this option is set, `upload-pack` will support partial
32743274
clone and partial fetch object filtering.
32753275
+
32763276
Note that this configuration variable is ignored if it is seen in the

upload-pack.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static int stateless_rpc;
6868
static const char *pack_objects_hook;
6969

7070
static int filter_capability_requested;
71-
static int filter_advertise;
71+
static int allow_filter;
7272
static struct list_objects_filter_options filter_options;
7373

7474
static void reset_timeout(void)
@@ -845,7 +845,7 @@ static void receive_needs(void)
845845
no_progress = 1;
846846
if (parse_feature_request(features, "include-tag"))
847847
use_include_tag = 1;
848-
if (parse_feature_request(features, "filter"))
848+
if (allow_filter && parse_feature_request(features, "filter"))
849849
filter_capability_requested = 1;
850850

851851
o = parse_object(&oid_buf);
@@ -975,7 +975,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
975975
" allow-reachable-sha1-in-want" : "",
976976
stateless_rpc ? " no-done" : "",
977977
symref_info.buf,
978-
filter_advertise ? " filter" : "",
978+
allow_filter ? " filter" : "",
979979
git_user_agent_sanitized());
980980
strbuf_release(&symref_info);
981981
} else {
@@ -1055,7 +1055,7 @@ static int upload_pack_config(const char *var, const char *value, void *unused)
10551055
if (!strcmp("uploadpack.packobjectshook", var))
10561056
return git_config_string(&pack_objects_hook, var, value);
10571057
} else if (!strcmp("uploadpack.allowfilter", var)) {
1058-
filter_advertise = git_config_bool(var, value);
1058+
allow_filter = git_config_bool(var, value);
10591059
}
10601060
return parse_hide_refs_config(var, value, "uploadpack");
10611061
}

0 commit comments

Comments
 (0)