Skip to content

Commit 2af8e50

Browse files
amartsthotz
authored andcommitted
server-protocol: don't allow '../' path in 'name'
This will prevent any arbitrary file creation through glusterfs by modifying the client bits. Also check for the similar flaw inside posix too, so we prevent any changes in layers in-between. Fixes: bz#1625095 Signed-off-by: Amar Tumballi <amarts@redhat.com> Change-Id: Id9fe0ef6e86459e8ed85ab947d977f058c5ae06e
1 parent 46fce2e commit 2af8e50

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

xlators/protocol/server/src/server-resolve.c

+12
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,18 @@ resolve_entry_simple (call_frame_t *frame)
311311
/* expected @parent was found from the inode cache */
312312
gf_uuid_copy (state->loc_now->pargfid, resolve->pargfid);
313313
state->loc_now->parent = inode_ref (parent);
314+
315+
if (strstr (resolve->bname, "../")) {
316+
/* Resolving outside the parent's tree is not allowed */
317+
gf_msg (this->name, GF_LOG_ERROR, EPERM,
318+
PS_MSG_GFID_RESOLVE_FAILED,
319+
"%s: path sent by client not allowed",
320+
resolve->bname);
321+
resolve->op_ret = -1;
322+
resolve->op_errno = EPERM;
323+
ret = 1;
324+
goto out;
325+
}
314326
state->loc_now->name = resolve->bname;
315327

316328
inode = inode_grep (state->itable, parent, resolve->bname);

xlators/storage/posix/src/posix-handle.h

+6
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@
142142
break; \
143143
} \
144144
\
145+
if (strstr (loc->name, "../")) { \
146+
gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_ENTRY_HANDLE_CREATE, \
147+
"'../' in name not allowed: (%s)", loc->name); \
148+
op_ret = -1; \
149+
break; \
150+
} \
145151
if (LOC_HAS_ABSPATH (loc)) { \
146152
MAKE_REAL_PATH (entp, this, loc->path); \
147153
__parp = strdupa (entp); \

0 commit comments

Comments
 (0)