Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Veracode Scan reported External Control of File Name or Path (CWE ID 73) issue #199

Open
dimas-isharmaya opened this issue Nov 1, 2021 · 0 comments

Comments

@dimas-isharmaya
Copy link

dimas-isharmaya commented Nov 1, 2021

We have PdfViewPager integrated in our Android mobile app that is already available in Google Play Store. As part of security implementation review, the app is being scanned using Veracode.

Issue is found on FileUtil.java where Veracode reported Server Directory Traversal Issues > External Control of File Name or Path (CWE ID 73) as a Medium severity. Report mentioned the issue is "This call contains a path manipulation flaw. The argument to the function is a filename constructed using untrusted input. If an attacker is allowed to specify all or part of the filename, it may be possible to gain unauthorized access to files on the server, including those outside the webroot, that would be normally be inaccessible to end users. The level of exposure depends on the effectiveness of input validation routines, if any."

The issue is reported on the following line of code from FileUtil.java:
com/.../library/util/FileUtil.java 28
com/.../library/util/FileUtil.java 29
com/.../library/util/FileUtil.java 31

public class FileUtil {
    public static boolean copyAsset(Context ctx, String assetName, String destinationPath) throws IOException {
        InputStream in = ctx.getAssets().open(assetName);
        File f = new File(destinationPath);
        f.createNewFile();
        OutputStream out = new FileOutputStream(new File(destinationPath));

        byte[] buffer = new byte[1024];
        int read;
        while ((read = in.read(buffer)) != -1) {
            out.write(buffer, 0, read);
        }
        in.close();
        out.close();

        return true;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant